Explore Library
Code QuizIntermediate

Bootstrap Sampling for Bagging

Find why this bootstrap sampler doesn't actually produce bootstrap samples.

Codepython
import random

def bootstrap_sample(data):
    n = len(data)
    sample = []
    indices = random.sample(range(n), n)
    for i in indices:
        sample.append(data[i])
    return sample

This should draw a bootstrap sample for a bagging ensemble. What is the bug?