확률적 경사 부스팅(SGB)

Python으로 배우는 트리 기반 Machine Learning

Elie Kawerk

Data Scientist

경사 부스팅: 단점

  • GB는 철저한 탐색 절차를 수행합니다.

  • 각 CART는 최적 분할 지점과 특성을 찾도록 학습됩니다.

  • 그 결과 CART들이 같은 분할 지점, 심지어 같은 특성을 사용할 수 있습니다.

Python으로 배우는 트리 기반 Machine Learning

확률적 경사 부스팅

  • 각 트리는 학습 데이터의 무작위 행 부분집합으로 학습됩니다.

  • 샘플된 인스턴스(학습 세트의 40%~80%)는 비복원 추출입니다.

  • 분할 지점 선택 시 특성도 비복원으로 샘플링합니다.

  • 결과: 앙상블 다양성 추가.

  • 효과: 트리 앙상블의 분산 추가.

Python으로 배우는 트리 기반 Machine Learning

확률적 경사 부스팅: 학습

SGB

Python으로 배우는 트리 기반 Machine Learning

scikit-learn의 확률적 경사 부스팅(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)
Python으로 배우는 트리 기반 Machine Learning

scikit-learn의 확률적 경사 부스팅(auto 데이터셋)

# Instantiate a stochastic GradientBoostingRegressor 'sgbt'
sgbt = GradientBoostingRegressor(max_depth=1, 
                                 subsample=0.8,
                                 max_features=0.2,
                                 n_estimators=300,             
                                 random_state=SEED)

# Fit 'sgbt' to the training set sgbt.fit(X_train, y_train) # Predict the test set labels y_pred = sgbt.predict(X_test)
Python으로 배우는 트리 기반 Machine Learning

scikit-learn의 확률적 경사 부스팅(auto 데이터셋)

# Evaluate test set RMSE 'rmse_test'
rmse_test = MSE(y_test, y_pred)**(1/2)

# Print 'rmse_test'
print('Test set RMSE: {:.2f}'.format(rmse_test))
Test set RMSE: 3.95
Python으로 배우는 트리 기반 Machine Learning

연습해 봅시다!

Python으로 배우는 트리 기반 Machine Learning

Preparing Video For Download...