开始使用免费开始使用

计算准确性指标:召回率

Recall(召回率)是衡量分类算法准确性的另一个重要指标。它被计算为真正例数占真正例与假负例之和的比例,即: $$\frac{\text{# of True Positives}}{\text{# of True Positives} + \text{# of False Negatives}}.$$

如果没有假负例,召回率等于 1。 如果没有真正例,召回率等于 0。

在本练习中,您将使用 sklearn 函数 recall_score 为初始分类模型计算召回率。

变量 features_testtarget_test 已在您的工作区中可用。

本练习是课程的一部分

HR Analytics:用 Python 预测员工流失

查看课程

练习说明

  • 导入用于计算召回率的函数。
  • 使用初始模型基于测试集的特征预测离职(churn)。
  • 通过比较 target_test 与预测结果来计算召回率。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Import the function to calculate recall score
from sklearn.____ import ____

# Use the initial model to predict churn
prediction = model.____(features_test)

# Calculate recall score by comparing target_test with the prediction
____(target_test, ____)
编辑并运行代码