GradientBoostingRegressor implementation.
Classes
class algorithms.ensemble.gradient_boosting_regressor.GradientBoostingRegressor(Regressor)
Gradient boosting for regression.
Builds an additive ensemble by iteratively fitting base regressors to the residuals (negative gradients) of the previous predictions.
Constructor
__init__( self, base_regressor: Optional[Regressor] = None, n_estimators: int = 100, shrinkage: float = 0.1, minimize_absolute_error: bool = False, )
Parameters
base_regressor
Regressor
The base regressor to use. If None, a simple decision stump is used.
n_estimators
int
= 100
The number of boosting iterations.
shrinkage
float
= 0.1
Learning rate/shrinkage factor.
minimize_absolute_error
bool
= False
Whether to use L1 loss (MAE) instead of L2 loss (MSE).
Attributes
estimators_
list of Regressor
The collection of fitted base regressors.
initial_prediction_
float
The initial prediction (mean or median of target values).
python
>>> from tuiml.algorithms.ensemble import GradientBoostingRegressor
>>> reg = GradientBoostingRegressor(n_estimators=50, shrinkage=0.1)
>>> reg.fit(X_train, y_train)
GradientBoostingRegressor(...)
>>> predictions = reg.predict(X_test)
References
1
Friedman, J. H. (2001). Greedy function approximation: A gradient
boosting machine. Annals of Statistics, 29(5), 1189-1232.
Methods
fit
(self, X: np.ndarray, y: np.ndarray) -> 'GradientBoostingRegressor'
fit
(self, X: np.ndarray, y: np.ndarray) -> 'GradientBoostingRegressor'
Fit the GradientBoostingRegressor model.
Parameters
X
np.ndarray of shape (n_samples, n_features)
Training features.
y
np.ndarray of shape (n_samples,)
Target values.
Returns
self
GradientBoostingRegressor
Returns the fitted instance.