Implement adaboost_fit(X, y, n_clf) for labels yi∈{−1,+1}. Start with uniform sample weights wi=1/n and repeat n_clf times:
- Candidate stumps: every feature j and every unique value t of
X[:, j] as threshold. A stump predicts h(x)=p⋅(+1 if xj≥t else −1), starting with polarity p=1.
- Weighted error ε=∑i:h(xi)=yiwi. If ε>0.5, set p=−1 and ε←1−ε.
- Keep the stump with the smallest ε (scan features in index order and thresholds in ascending order; replace the best only on a strictly smaller error).
- α=21lnε+10−101−ε.
- Update wi←wiexp(−αyih(xi)) and renormalize so the weights sum to 1.
Return a list of n_clf dicts, each {'polarity': p, 'threshold': t, 'feature_index': j, 'alpha': alpha} with the keys in that order.