SKLearner Home | About | Contact | Examples

Configure GradientBoostingRegressor "alpha" Parameter

The alpha parameter in scikit-learn’s GradientBoostingRegressor controls the quantile in the quantile loss function.

GradientBoostingRegressor is a machine learning technique for regression problems. It builds an additive model in a forward stage-wise manner, allowing for flexible and robust regression modeling.

The alpha parameter specifies the quantile to be used in the quantile loss function, ranging between 0 and 1. Lower values focus on lower quantiles, while higher values focus on upper quantiles.

The default value for alpha is 0.9. Common values used in practice depend on the specific requirements for quantile estimation.

from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.metrics import mean_absolute_error

# Generate synthetic dataset
X, y = make_regression(n_samples=1000, n_features=10, noise=0.1, random_state=42)

# Split into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Train with different alpha values
alpha_values = [0.1, 0.5, 0.9]
errors = []

for alpha in alpha_values:
    gbr = GradientBoostingRegressor(loss='quantile', alpha=alpha, random_state=42)
    gbr.fit(X_train, y_train)
    y_pred = gbr.predict(X_test)
    error = mean_absolute_error(y_test, y_pred)
    errors.append(error)
    print(f"alpha={alpha}, Mean Absolute Error: {error:.3f}")

Running the example gives an output like:

alpha=0.1, Mean Absolute Error: 83.232
alpha=0.5, Mean Absolute Error: 34.044
alpha=0.9, Mean Absolute Error: 66.952

The key steps in this example are:

  1. Generate a synthetic regression dataset with noise.
  2. Split the data into training and testing sets.
  3. Train GradientBoostingRegressor models with different alpha values.
  4. Evaluate the mean absolute error of each model on the test set.

Some tips and heuristics for setting alpha:

Issues to consider:



See Also