GBoostRegressor#

class GBoostRegressor(base_estimator=RuleTreeRegressor(base_stumps=DecisionTreeStumpRegressor(), max_depth=3), n_estimators=100, learning_rate=0.1, loss='squared_loss', patience=5, val_size=0.15, random_state=42)[source]#

Bases: RegressorMixin, RuleTreeBase

Gradient boosting for regression with RuleTrees as base estimators (squared loss).

Each estimator is fitted on the residuals of the previous ones; the boosting stops early when the error on a validation set does not improve for patience iterations.

Parameters:
  • base_estimator (RuleTreeRegressor, default=RuleTreeRegressor(max_depth=3)) – Estimator fitted at each iteration.

  • n_estimators (int, default=100) – Maximum number of estimators.

  • learning_rate (float, default=0.1) – Shrinkage of the contribution of each estimator.

  • loss ('squared_loss' or callable, default='squared_loss') – Checked but not used: the loss is always the squared loss.

  • patience (int, default=5) – Number of iterations without improvement before stopping.

  • val_size (float, default=0.15) – Fraction of the training set used for validation.

  • random_state (int, default=42) – Seed of the split between training and validation, and of the trees whose base estimator has no random_state (each tree gets a different seed drawn from it).

Variables:
  • base_prediction (float) – Initial prediction (mean of the target).

  • estimators (list of RuleTreeRegressor) – Fitted estimators.

See also

XGBoostRegressor

the boosting of the XGBoost trees.

EBMRegressor

a boosting of trees on single features and pairs of features.

Examples

>>> from sklearn.datasets import load_diabetes
>>> from RuleTree import RuleTreeRegressor
>>> from RuleTree.ensemble.GBoostRegressor import GBoostRegressor
>>> X, y = load_diabetes(return_X_y=True)
>>> model = GBoostRegressor(base_estimator=RuleTreeRegressor(max_depth=2, random_state=0),
...                         n_estimators=20, random_state=0).fit(X, y)
>>> len(model.estimators_), round(model.score(X, y), 3)
(20, 0.531)
fit(X: ndarray, y: ndarray)[source]#

Fit the boosting.

Parameters:
  • X (numpy.ndarray of shape (n_samples, n_features)) – Tabular data.

  • y (numpy.ndarray of shape (n_samples,) or (n_samples, n_targets)) – Target.

Returns:

self

Return type:

GBoostRegressor

predict(X: ndarray)[source]#

Predict the target: the initial prediction plus the contributions of all the estimators.

Parameters:

X (numpy.ndarray of shape (n_samples, n_features)) – Tabular data.

Returns:

y_pred

Return type:

numpy.ndarray of shape (n_samples,) or (n_samples, n_targets)