AdaBoost weighting
Quick answer
AdaBoost changes the weight of training examples after each classifier. Incorrectly classified examples receive more relative influence in the next round. Better-performing learners receive more influence in the final ensemble. Examples are static and locally tested with Python 3.13.5, scikit-learn 1.8.0 and NumPy 2.3.5 where imported. ByteMind package execution is unverified.
Reweight a binary round
from fractions import Fraction as Fw = [F(1,4)]*4wrong = [False,False,False,True]# Equivalent relative multipliers for e=1/4: correct 1, wrong 3.raw = [v*(3 if bad else 1) for v,bad in zip(w,wrong)]print([str(v/sum(raw)) for v in raw])Observed local output:
['1/6', '1/6', '1/6', '1/2']Half of the next-round probability mass is assigned to the one mistaken row.
How it works
For the classic binary derivation, let labels and predictions be -1 or +1 and let nonnegative training weights sum to one. The weighted error e = sum(w_i for misclassified i). If 0 < e < 0.5, alpha = 0.5 ln((1-e)/e) is positive. Multiply each weight by exp(-alpha y_i h_i) and normalize the result to sum to one. Correct predictions have y_i h_i = 1, so their weights shrink relative to mistakes. Incorrect predictions have product -1. For four equally weighted rows with one mistake, e=0.25, alpha=0.5 ln 3, and after normalization the mistaken row has weight 0.5 while each correct row has weight 1/6. Prediction is the sign of the sum of weighted signed votes, with a stated tie rule. The binary derivation uses exponential loss; scikit-learn 1.8 AdaBoostClassifier implements discrete SAMME, whose learner-weight convention differs from this half-log formula. With K classes, its unscaled coefficient is ln((1-e)/e)+ln(K-1), and the admissible error is below 1-1/K. Its estimator parameter selects a learner that supports sample_weight. At e=0 the theoretical coefficient diverges; a real implementation needs a stopping convention. At chance or worse, the positive-weight derivation no longer applies. Label noise can attract repeated emphasis, so inspect errors rather than blindly adding rounds.
Fit a discrete AdaBoost classifier
from sklearn.ensemble import AdaBoostClassifierfrom sklearn.tree import DecisionTreeClassifierX = [[0],[1],[2],[3]]y = [0,0,1,1]m = AdaBoostClassifier(estimator=DecisionTreeClassifier(max_depth=1), n_estimators=5, random_state=7).fit(X,y)print(m.predict(X).tolist())print(len(m.estimators_))Observed local output:
[0, 0, 1, 1]1The first learner separates the rows perfectly; training terminates early instead of fitting five trees.
Common mistakes
Do not count errors without their current weights. Do not apply the half-log binary coefficient directly to scikit-learn’s multiclass implementation. Do not divide by zero when a perfect learner occurs; stop or use the implementation’s documented rule.
Practice and next steps
For weights [0.1, 0.2, 0.3, 0.4] and mistakes at positions 0 and 1, calculate weighted error and decide whether the classic binary alpha is positive. Complete the knowledge check and staged exercise. Next: Negative gradients and residual updates.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
AdaBoost weighting — knowledge check
Apply adaboost weighting to new examples.
Weights [0.2,0.3,0.5]; only the last row is wrong. Weighted error?
For classic binary AdaBoost with e=0.25, what happens to relative weight of mistakes?
Why normalize after reweighting?
What is the safe theoretical response when e=0?
Why can noisy labels hurt AdaBoost?