開始使用免費開始

計算準確性指標:Recall

Recall(召回率)是用來衡量分類演算法準確性的另一個重要指標。它的計算方式是:將 True Positives 除以 True Positives 與 False Negatives 之和,也就是 $$\frac{\text{# of True Positives}}{\text{# of True Positives} + \text{# of False Negatives}}.$$

如果沒有任何 False Negatives,則 recall 分數等於 1。 如果沒有任何 True Positives,則 recall 分數等於 0。

在這個練習中,你將使用 sklearn 的 recall_score 函式,為你的一開始的分類模型計算 recall 分數。

變數 features_testtarget_test 已經在你的工作空間中可用。

本練習屬於課程

HR 分析:用 Python 預測員工流失

檢視課程

練習說明

  • 匯入用來計算 recall 分數的函式。
  • 使用初始模型根據測試集的特徵來預測是否會流失。
  • 比較 target_test 與預測結果,計算 recall 分數。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# 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, ____)
編輯並執行程式碼