AdaBoostClassifier classifier implementation.
Classes
AdaBoostClassifier for adaptive boosting in multiclass classification.
__init__( self, base_classifier: Any = 'DecisionStumpClassifier', n_estimators: int = 50, weight_threshold: float = 100, random_state: Optional[int] = None, )
Overview
The algorithm proceeds as follows:
- Initialize uniform sample weights w_i = 1/n for all training instances
- For each boosting iteration t = 1, \ldots, T:
- Combine all weak learners via weighted majority vote
Theory
The weighted classification error at iteration t is:
The estimator weight for the multiclass case (SAMME) is:
where K is the number of classes. Sample weights are updated as:
The final prediction is obtained by weighted majority vote:
Parameters
base_classifier
n_estimators
weight_threshold
random_state
Attributes
estimators_
estimator_weights_
classes_
fit().
Notes
Complexity:
- Training: O(T \cdot n \cdot C_{\text{base}}) where T = n_estimators,
- Prediction: O(T \cdot C_{\text{predict}}) per sample
- When a simple base learner (e.g., decision stump) needs to be boosted
- Binary or multiclass classification tasks with moderate noise
- When you want an interpretable ensemble (weighted sum of simple rules)
- When training data is relatively clean (AdaBoost is sensitive to outliers)
References
See Also
Basic usage for multiclass classification with AdaBoost:
>>> from tuiml.algorithms.ensemble import AdaBoostClassifier
>>> import numpy as np
>>>
>>> # Create sample training data
>>> X_train = np.array([[1, 2], [2, 3], [3, 1], [4, 3], [5, 2]])
>>> y_train = np.array([0, 0, 1, 1, 1])
>>>
>>> # Fit the AdaBoost classifier
>>> clf = AdaBoostClassifier(n_estimators=50, random_state=42)
>>> clf.fit(X_train, y_train)
AdaBoostClassifier(...)
>>> predictions = clf.predict(X_train)
Methods
get_parameter_schema
(cls) -> Dict[str, Dict[str, Any]]
get_capabilities
(cls) -> List[str]
get_complexity
(cls) -> str
get_references
(cls) -> List[str]
__repr__
(self) -> str
AdaBoost.R2 regressor for adaptive boosting in regression tasks.
__init__( self, base_regressor: Any = 'GradientBoostingRegressor', n_estimators: int = 10, random_state: Optional[int] = None, )
Overview
The algorithm proceeds as follows:
- Initialize uniform sample weights w_i = 1/n
- For each boosting iteration t = 1, \ldots, T:
- Combine estimators using the weighted median
Theory
The relative loss for each sample at iteration t is:
where D_t = \max_i |y_i - h_t(x_i)| is the maximum absolute error. The weighted average loss is:
The estimator confidence is:
Weights are updated as:
The final prediction is the weighted median of all estimator predictions, using \log(1/\beta_t) as the estimator weight.
Parameters
base_regressor
n_estimators
random_state
Attributes
estimators_
estimator_weights_
Notes
Complexity:
- Training: O(T \cdot n \cdot C_{\text{base}}) where T = n_estimators
- Prediction: O(T \cdot n \cdot \log T) per batch due to weighted median
- When a simple base regressor needs to be boosted for better accuracy
- Regression tasks with moderate noise levels
- When you want an interpretable ensemble of simple models
- When training data is relatively clean (AdaBoost is sensitive to outliers)
References
See Also
Basic usage for regression with AdaBoost.R2:
>>> from tuiml.algorithms.ensemble import AdaBoostRegressor
>>> import numpy as np
>>> X_train = np.array([[1], [2], [3], [4], [5]])
>>> y_train = np.array([1.0, 4.0, 9.0, 16.0, 25.0])
>>> reg = AdaBoostRegressor(n_estimators=50, random_state=42)
>>> reg.fit(X_train, y_train)
AdaBoostRegressor(...)