Gradient Boosting (GB)

Machine Learning dengan Model Berbasis Pohon di Python

Elie Kawerk

Data Scientist

Gradient Boosted Trees

  • Koreksi berurutan atas galat model sebelumnya.

  • Tidak menyesuaikan bobot instance latih.

  • Tiap prediktor dilatih dengan residual pendahulunya sebagai label.

  • Gradient Boosted Trees: CART dipakai sebagai learner dasar.

Machine Learning dengan Model Berbasis Pohon di Python

Gradient Boosted Trees untuk Regresi: Pelatihan

Pelatihan GBT

Machine Learning dengan Model Berbasis Pohon di Python

Shrinkage

Laju belajar GBT

Machine Learning dengan Model Berbasis Pohon di Python

Gradient Boosted Trees: Prediksi

  • Regresi:

    • $y_{pred} = y_1 + \eta r_1 + ... + \eta r_N$
    • Di sklearn: GradientBoostingRegressor.
  • Klasifikasi:

    • Di sklearn: GradientBoostingClassifier.
Machine Learning dengan Model Berbasis Pohon di Python

Gradient Boosting di sklearn (dataset 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 dengan Model Berbasis Pohon di 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 dengan Model Berbasis Pohon di Python

Ayo berlatih!

Machine Learning dengan Model Berbasis Pohon di Python

Preparing Video For Download...