員工離職模型比較
在這個練習中,你要使用經過剪枝的樹(max_depth=7)比較「balanced」與「imbalanced」(預設)兩種模型。imbalanced 模型已經替你計算了 recall 與 ROC/AUC 分數。請為 balanced 模型完成相同步驟。
- 變數
features_train、target_train、features_test與target_test已經在你的工作環境中。 - 已替你訓練好一個 imbalanced 模型,且其預測結果已儲存為
prediction。 recall_score()與roc_auc_score()函式已替你匯入。
本練習屬於課程
HR 分析:用 Python 預測員工流失
練習說明
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# 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(____)