중요한 특성 선택하기
이번 연습에서는 최종 모델에 사용할 가장 중요한 특성만 선택하는 것이 목표입니다. 상대적 중요도는 relative_importances라는 DataFrame의 importance 열에 저장되어 있음을 기억하세요.
이 연습은 강의의 일부입니다
HR Analytics: Python으로 직원 이탈 예측하기
연습 안내
importance값이 1%보다 큰 특성만 선택하세요.- 해당 특성들로 리스트를 만들고 출력하세요(이미 제공되어 있습니다).
selected_list에 저장된 인덱스를 사용해,features_train과features_test모두를 중요도가 1%보다 큰 특성만 포함하도록 변환하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# select only features with relative importance higher than 1%
selected_features = relative_importances[relative_importances.____>0.01]
# create a list from those features: done
selected_list = selected_features.index
# transform both features_train and features_test components to include only selected features
features_train_selected = features_train[selected_list]
features_test_selected = ____[____]