Majority voting needs trees that are not exact copies. Bagging creates that diversity by training the same learner on many same-sized random samples drawn with replacement. A row may appear repeatedly or not at all, but its label must always travel with it.
Implement bootstrap_sample and train_random_forest. Draw paired bootstrap rows, then train exactly n_trees with the existing build_tree function.
input.shape[0] indices from [0, n_samples) with replacement.input and labels.np.random.default_rng(seed) before the tree loop.n_trees independently bootstrapped build_tree results.Open one at a time. Each gives away a little more than the last.
Replacement means an index-drawing operation may repeat a value; it does not need a permutation.
Pass one advancing generator into each bootstrap call rather than re-creating it inside the loop.
No results yet
Run your code to check it against the examples, or submit to run every test.