始める無料で始める

従業員離職モデルの比較

この演習では、剪定済みツリー(max_depth=7)を使って、バランスあり モデルと バランスなし(デフォルト)モデルを比較します。バランスなし モデルについては、すでに recallROC/AUC スコアを計算済みです。バランスあり モデルでも同じ手順を完成させてください。

  • 変数 features_traintarget_trainfeatures_testtarget_test はワークスペースに用意されています。
  • バランスなしモデルはすでに学習済みで、その予測は prediction に保存されています。
  • recall_score()roc_auc_score() 関数はインポート済みです。

この演習はコースの一部です

HRアナリティクス:Pythonで従業員離職を予測する

コースを見る

演習の手順

  • バランスありモデルを初期化し、最大深さを 7、乱数シードを 42 に設定します。
  • トレーニングセットを使って学習用データにフィットさせます。
  • テストセットを使って予測を行います。
  • 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(____)
コードを編集して実行