开始使用免费开始使用

员工离职预测模型对比

在本练习中,您的任务是使用剪枝后的树(max_depth=7)对比均衡不均衡(默认)模型。已为您计算了不均衡模型的 recallROC/AUC 分数。请为均衡模型完成相同步骤。

  • 变量 features_traintarget_trainfeatures_testtarget_test 已在工作区中可用。
  • 已为您拟合了一个不均衡模型,并将其预测结果保存为 prediction
  • 函数 recall_score()roc_auc_score() 已为您导入。

本练习是课程的一部分

HR Analytics:用 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(____)
编辑并运行代码