본문 바로가기

ML,DL

Random Forests

참고 : https://www.kaggle.com/nickneim/exercise-random-forests/edit

참고 : https://sdsf1225.tistory.com/25

  • Decision-Tree에서는 Underfitting과 Overfitting의 문제 사이에서 Sweet-spot을 찾는 것이 문제점이라고 다뤘었다
  • Random Forests기법은 Decision-Tree의 이러한 문제점을 보완하기 위해서 1개의 Tree가 아니라 여러개의 'Trees'를 사용해서 각 Tree의 평균을 구해서 예측에 활용한다

간단한 Random Forest 구현

from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error

forest_model = RandomForestRegressor(random_state=1)
forest_model.fit(train_X, train_y)
melb_preds = forest_model.predict(val_X)
print(mean_absolute_error(val_y, melb_preds))
# Output

191669.7536453626

지난 Decision-Tree기법에서의 MAE에 비해 월등히 낮아졌음을 확인할 수 있다.

'ML,DL' 카테고리의 다른 글

Ensemble - Bagging, Boosting, Stacking  (0) 2023.03.08
Optimization - Cross validation, Bias & Variance, Bootstrapping  (0) 2023.03.08
Underfitting & Overfitting  (0) 2021.08.26
Model Validation(모델 검증)  (2) 2021.08.21
로지스틱 회귀분석  (0) 2021.08.16