시작하기무료로 시작하기

Employee 이탈 예측 모델 비교

이 연습 문제에서는 가지치기한 트리(max_depth=7)를 사용해 balanced 모델과 imbalanced(기본값) 모델을 비교해 보겠습니다. imbalanced 모델에 대해서는 이미 recallROC/AUC 점수를 계산해 두었습니다. 같은 절차를 balanced 모델에도 적용해 보세요.

  • features_train, target_train, features_test, target_test 변수는 워크스페이스에 준비되어 있습니다.
  • imbalanced 모델은 이미 학습되었고 예측값은 prediction으로 저장되어 있습니다.
  • recall_score()roc_auc_score() 함수는 미리 임포트되어 있습니다.

이 연습은 강의의 일부입니다

HR Analytics: Python으로 직원 이탈 예측하기

강의 보기

연습 안내

  • 최대 깊이를 7, 시드를 42로 설정해 balanced 모델을 초기화하세요.
  • 학습용 데이터로 모델을 학습시키세요.
  • 테스트 세트를 사용해 예측을 만드세요.
  • recall 점수ROC/AUC 점수를 출력하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Print the recall score
print(recall_score(target_test,prediction))
# Print the ROC/AUC score
print(roc_auc_score(target_test,prediction))

# Initialize the model
model_depth_7_b = 
# Fit it to the training component
model_depth_7_b.fit(____,____)
# Make prediction using test component
prediction_b = 
# Print the recall score for the balanced model
print(____)
# Print the ROC/AUC score for the balanced model
print(____)
코드 편집 및 실행