Gradient Boosting (GB)

Machine Learning cu modele bazate pe arbori în Python

Elie Kawerk

Data Scientist

Arbori Gradient Boosted

  • Corectarea secvențială a erorilor predecesorului.

  • Nu modifică ponderile instanțelor de antrenament.

  • Fiecare predictor este antrenat folosind erorile reziduale ale predecesorului ca etichete.

  • Arbori Gradient Boosted: un CART este utilizat ca învățător de bază.

Machine Learning cu modele bazate pe arbori în Python

Arbori Gradient Boosted pentru Regresie: Antrenare

Antrenare GBT

Machine Learning cu modele bazate pe arbori în Python

Contracție

GBT-rată de învățare

Machine Learning cu modele bazate pe arbori în Python

Arbori Gradient Boosted: Predicție

  • Regresie:

    • $y_{pred} = y_1 + \eta r_1 + ... + \eta r_N$
    • În sklearn: GradientBoostingRegressor.
  • Clasificare:

    • În sklearn: GradientBoostingClassifier.
Machine Learning cu modele bazate pe arbori în Python

Gradient Boosting în sklearn (setul de date auto)

# Import models and utility functions
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error as MSE

# Set seed for reproducibility
SEED = 1

# Split dataset into 70% train and 30% test
X_train, X_test, y_train, y_test = train_test_split(X,y, 
                                                    test_size=0.3, 
                                                    random_state=SEED)
Machine Learning cu modele bazate pe arbori în Python
# Instantiate a GradientBoostingRegressor 'gbt'
gbt = GradientBoostingRegressor(n_estimators=300, max_depth=1, random_state=SEED)

# Fit 'gbt' to the training set gbt.fit(X_train, y_train) # Predict the test set labels y_pred = gbt.predict(X_test) # Evaluate the test set RMSE rmse_test = MSE(y_test, y_pred)**(1/2) # Print the test set RMSE print('Test set RMSE: {:.2f}'.format(rmse_test))
Test set RMSE: 4.01
Machine Learning cu modele bazate pe arbori în Python

Să exersăm!

Machine Learning cu modele bazate pe arbori în Python

Preparing Video For Download...