본문 바로가기

Machine Learning/변수 선택(Feature Selection)

Feature Selection - Feature_importances

반응형

https://steadiness-193.tistory.com/261

 

Classification - RandomForestClassifier

https://steadiness-193.tistory.com/257 Machine Learning - valid와 test를 train으로 전처리 https://steadiness-193.tistory.com/256 Machine Learning - train_test_split https://steadiness-193.tistory.co..

steadiness-193.tistory.com

 

https://steadiness-193.tistory.com/263

 

Classification - XGBClassifier

[XGBoost] 부트스트래핑(Bootstrapping) 방식의 앙상블 알고리즘 부트스트래핑 : 임의로 샘플 및 변수를 선택하여 학습 부스팅 알고리즘 (Boosting algorithm) 각 트리(이터레이션)가 맞히지 못한 샘플에 대��

steadiness-193.tistory.com

 

위 두개의 포스팅에서 트리 계열의 featuer_importances와

 

이를 바로 그릴 수 있는 plot_importance를 알아보았다.

 

 

 

위 내용을 변수 선택에 이용해보자

 

 

 

https://steadiness-193.tistory.com/257

 

Machine Learning - valid와 test를 train으로 전처리

https://steadiness-193.tistory.com/256 Machine Learning - train_test_split https://steadiness-193.tistory.com/253 Machine Learning - 랜덤으로 train과 test로 나누기 데이터 불러오기 seaborn의 iris 데..

steadiness-193.tistory.com

 

위 포스팅에서 만든 데이터셋을 이용한다.

 

 

 

 

전체 컬럼, 정확도 80.22%

 

 

 

 

 

 

 

변수 중요도 확인

 

 

 

여기서 2분위수 이상의 값을 가진 컬럼,

 

3분위수 이상의  값을 가진 컬럼을 구분해서 다시 정확도를 측정한다.

 

 

 

 

 

 

 

 

2분위 수 이상 (0.000587 이상)

 

 

컬럼의 수는 24개

 

 

 

정확도는 79.48%

 

 

 

 

 

3분위 수 이상 (0.013076 이상)

 

 

컬럼은 12개

 

 

 

 

정확도는 80.97%

 

 

RandomForest 기준으로

feature importance가 3분위수 이상 값을 가진 컬럼으로 예측을 했을 때 정확도가 가장 높았다.

 

 

 

 

정리

 

  전체 2분위 3분위
컬럼의 수 48개 24개 12개
정확도 80.22% 79.48% 80.97%

 

 

 

그러나 이를 맹신하는 것은 위험하다.

 

그 이유는 다음과 같다.

 

 

1. 기준을 2, 3 사분위수로 한 것은 임의로 한 것과 크게 다르지 않다.

 

2. Random Forest를 기준으로 했기 때문에 XGBoost나 LGBM의 경우는 변수 중요도와 정확도가

또 어떻게 나올지 알 수 없다.

 

3. 앙상블 트리 계열 특성 상 컬럼과 행 순서에 따라 결과가 다소 다르게 나온다.

 

 

위 내용을 고려하여 도메인 지식과 경험적 실험을 통해 좋은 변수를 가려내는 것이 최선이다.

반응형