AdaBoost Fit Method

Tree Models & Ensembles DS practice problem on Onlearn.

Difficulty: medium.

Topics: AdaBoost Fit Method, Exponential Loss Function, Sample Re-weighting, Stump Classifier, Stage-wise Additive Modeling, Learner Error Rate, Supervised Learning, Ensemble Methods, Computational Statistics, Optimization Theory, Model Evaluation, Boosting Algorithms, Decision Tree Induction, Iterative Weight Updating, Additive Modeling, Weak Learner Theory.

Write a Python function adaboost fit that implements the fit method for an AdaBoost classifier. The function should take in a 2D numpy array X of shape (n samples, n features) representing the dataset, a 1D numpy array y of shape (n samples,) representing the labels, and an integer n clf representing the number of classifiers. The function should initialize sample weights, find the best thresholds for each feature, calculate the error, update weights, and return a list of classifiers with their parameters.