직원 데이터에 트리 모델 학습시키기
Train/Test 분할을 사용하면 훈련용 데이터로 분류기를 개발하고, 나머지 데이터셋으로 테스트할 수 있습니다. 이 연습 문제에서는 decision tree 분류 알고리즘을 사용해 직원 이직 예측 모델 개발을 시작하겠습니다. 이 알고리즘은 .fit() 메서드를 제공하며, 훈련 세트에서 특성을 모델에 학습시키는 데 사용할 수 있습니다.
알림: 타깃과 특성은 이미 Train/Test로 분할되어 있습니다 (Train: features_train, target_train, Test: features_test, target_test).
이 연습은 강의의 일부입니다
HR Analytics: Python으로 직원 이탈 예측하기
연습 안내
DecisionTreeClassifier라는 분류 알고리즘을 임포트하세요.- 이를
model로 초기화하고 random_state를 42로 설정하세요. - 훈련 세트의 특성을
model에 맞춰 학습시켜 decision tree 모델을 적용하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Import the classification algorithm
from sklearn.tree import ____
# Initialize it and call model by specifying the random_state parameter
model = ____(random_state=42)
# Apply a decision tree model to fit features to the target
model.____(features_train, ____)