Explore Library
Code QuizIntermediate

Out-of-Bag Error Estimation

Finding the condition mistake in an out-of-bag prediction routine.

Codepython
def oob_predict(tree, X, bootstrap_idx):
    preds = {}
    for i in range(len(X)):
        # use samples that were left out of this tree's bootstrap
        if i in bootstrap_idx:
            preds[i] = tree.predict([X[i]])[0]
    return preds

What is the bug in this out-of-bag prediction code?