EBMRegressor#
- class EBMRegressor(n_iterations=100, base_estimator=RuleTreeRegressor(base_stumps=DecisionTreeStumpRegressor(), max_depth=6, random_state=42), learning_rate=0.04, val_size=0.15, patience=5, n_jobs=1, random_state=42)[source]#
Bases:
RegressorMixin,RuleTreeBaseExplainable boosting machine for regression: a cyclic gradient boosting where each base estimator is fitted on a single feature or on a pair of features, so that the prediction is a sum of functions of one or two features.
At each iteration, a copy of the base estimator is fitted on the residuals for each feature and each pair of features. The boosting stops early when the error on a validation set does not improve for
patienceiterations.- Parameters:
n_iterations (int, default=100) – Maximum number of iterations.
base_estimator (RuleTreeRegressor, default=RuleTreeRegressor(max_depth=6, random_state=42)) – Estimator fitted on each feature and pair of features.
learning_rate (float, default=0.04) – Shrinkage of the contribution of each estimator.
val_size (float, default=0.15) – Fraction of the training set used for validation.
patience (int, default=5) – Number of iterations without improvement before stopping.
n_jobs (int, default=1) – Not used.
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:
See also
GBoostRegressora boosting of trees on all the features.
Examples
>>> from sklearn.datasets import load_diabetes >>> from RuleTree import RuleTreeRegressor >>> from RuleTree.ensemble.EBMRegressor import EBMRegressor >>> X, y = load_diabetes(return_X_y=True) >>> model = EBMRegressor(base_estimator=RuleTreeRegressor(max_depth=1, random_state=0), ... n_iterations=5, learning_rate=0.1, random_state=0).fit(X, y) >>> len(model.estimators_) # 10 features and 45 pairs of features 55 >>> len(model.estimators_[(0, 1)]) # trees on the pair of features 0 and 1 5
- fit(X, y)[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:
- 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)