Bagging Classifier from Scratch

Tree Models & Ensembles DS practice problem on Onlearn.

Difficulty: medium.

Topics: Understanding Ensemble Learning via Bootstrap Aggregating, Sampling with Replacement, Majority Voting Rules, Parallel Model Training, Base Estimator Cloning, Deterministic Random State Management, Ensemble Learning, Supervised Learning, Statistical Sampling, Model Evaluation, Computational Complexity, Bootstrap Aggregating, Variance Reduction, Decision Tree Induction, Voting Systems, Out-of-Bag Estimation.

Implement a BaggingClassifier class from scratch that takes a base estimator, the number of estimators, and a random seed. The class must implement 'fit(X, y)' to train the ensemble and 'predict(X)' to aggregate predictions via majority voting. Assume the base estimator has a 'fit' and 'predict' method.