従業員離職モデルの比較
この演習では、剪定済みツリー(max_depth=7)を使って、バランスあり モデルと バランスなし(デフォルト)モデルを比較します。バランスなし モデルについては、すでに recall と ROC/AUC スコアを計算済みです。バランスあり モデルでも同じ手順を完成させてください。
- 変数
features_train、target_train、features_test、target_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(____)