The core logic isn't that hard once you break it down.
Start by clarifying the interface and assumptions: base classifier must support fit and predict, and we need to store multiple classifiers. Then implement fit by generating bootstrap samples (sampling with replacement) and training a clone of the base classifier on each. For predict, collect predictions from all classifiers and return the majority vote (mode) for each sample.
Pro tip: Mention that you would use a fresh clone of the base classifier for each bootstrap sample to avoid overwriting, and that you can optionally use parallelization (e.g., joblib) for efficiency. Also, note that ties in majority vote can be broken by a predefined rule (e.g., lowest class label).
Confirm that the base classifier has fit and predict methods, and that we need to store n_estimators classifiers. Ask about tie-breaking and whether probabilities are needed.
For each of n_estimators: generate a bootstrap sample by sampling indices with replacement from the training data, clone the base classifier, fit it on the sample, and store the trained classifier.
For each classifier, get predictions on X. Then for each sample, aggregate predictions via majority vote (e.g., using scipy.stats.mode or a custom counter) and return the array of predicted labels.
Discuss tie-breaking, parallel training, memory considerations, and potential use of out-of-bag samples for validation.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.