Explore Library
Code QuizIntermediate

Decision Tree Traversal

Find the branching mistake in a decision-tree prediction walk.

Codepython
def predict(node, x):
    while node['type'] != 'leaf':
        if x[node['feature']] <= node['threshold']:
            node = node['right']
        else:
            node = node['left']
    return node['value']

A tree is built so samples with value <= threshold belong on the left. What is the bug?