An AdaBoost regressor.
An AdaBoost 1
regressor is a meta-estimator that begins by fitting a regressor on the original dataset and then fits additional copies of the regressor on the same dataset but where the weights of instances are adjusted according to the error of the current prediction. As such, subsequent regressors focus more on difficult cases.
This class implements the algorithm known as AdaBoost.R2 2
.
Read more in the :ref:`User Guide <adaboost>`.
.. versionadded:: 0.14
Parameters ---------- base_estimator : object, default=None The base estimator from which the boosted ensemble is built. If ``None``, then the base estimator is ``DecisionTreeRegressor(max_depth=3)``.
n_estimators : int, default=50 The maximum number of estimators at which boosting is terminated. In case of perfect fit, the learning procedure is stopped early.
learning_rate : float, default=1. Learning rate shrinks the contribution of each regressor by ``learning_rate``. There is a trade-off between ``learning_rate`` and ``n_estimators``.
loss : 'linear', 'square', 'exponential'
, default='linear' The loss function to use when updating the weights after each boosting iteration.
random_state : int or RandomState, default=None Controls the random seed given at each `base_estimator` at each boosting iteration. Thus, it is only used when `base_estimator` exposes a `random_state`. In addition, it controls the bootstrap of the weights used to train the `base_estimator` at each boosting iteration. Pass an int for reproducible output across multiple function calls. See :term:`Glossary <random_state>`.
Attributes ---------- base_estimator_ : estimator The base estimator from which the ensemble is grown.
estimators_ : list of classifiers The collection of fitted sub-estimators.
estimator_weights_ : ndarray of floats Weights for each estimator in the boosted ensemble.
estimator_errors_ : ndarray of floats Regression error for each estimator in the boosted ensemble.
feature_importances_ : ndarray of shape (n_features,) The impurity-based feature importances if supported by the ``base_estimator`` (when based on decision trees).
Warning: impurity-based feature importances can be misleading for high cardinality features (many unique values). See :func:`sklearn.inspection.permutation_importance` as an alternative.
Examples -------- >>> from sklearn.ensemble import AdaBoostRegressor >>> from sklearn.datasets import make_regression >>> X, y = make_regression(n_features=4, n_informative=2, ... random_state=0, shuffle=False) >>> regr = AdaBoostRegressor(random_state=0, n_estimators=100) >>> regr.fit(X, y) AdaBoostRegressor(n_estimators=100, random_state=0) >>> regr.predict([0, 0, 0, 0]
) array(4.7972...
) >>> regr.score(X, y) 0.9771...
See also -------- AdaBoostClassifier, GradientBoostingRegressor, sklearn.tree.DecisionTreeRegressor
References ---------- .. 1
Y. Freund, R. Schapire, 'A Decision-Theoretic Generalization of on-Line Learning and an Application to Boosting', 1995.
.. 2
H. Drucker, 'Improving Regressors using Boosting Techniques', 1997.