The core idea isn't hard but I spent too long second-guessing the bootstrap sampling part.
Start by clarifying the problem and assumptions, then outline the bagging algorithm: generate bootstrap samples, train base classifiers, and aggregate predictions via majority vote. Implement fit and predict methods, and discuss trade-offs like computational cost and variance reduction.
Pro tip: Mention that bagging reduces variance without increasing bias, making it effective for high-variance models like decision trees, and highlight that it's embarrassingly parallel, which is crucial for scalability at a company like Coinbase.
Ask about the base classifier interface, data size, and whether bootstrap sampling should be with replacement. Confirm that majority vote is for classification and handle ties if necessary.
Decide on the number of estimators (e.g., 10-100). For each estimator, create a bootstrap sample by sampling with replacement from the training data, then train the base classifier on that sample.
In fit(X, y), loop over the number of estimators, generate bootstrap indices, extract the corresponding X and y, and train a clone of the base classifier. Store the trained models in a list.
In predict(X), collect predictions from each base classifier, then perform majority vote (e.g., using mode) to return the final prediction for each input.
Mention that bagging increases training time linearly with the number of estimators but can be parallelized. Also note that it reduces variance and helps with overfitting, but may not help with high-bias models.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.