選取報表指標
classification_report() 內含許多不同的指標,但你不一定每次都想列出完整報表。有時你只需要特定數值,來比較模型或用於其他目的。
在 scikit-learn 中有個函式可以幫你擷取這些數值。該函式是 precision_recall_fscore_support(),它接受與 classification_report 相同的參數。
匯入與使用方式如下:
# Import function
from sklearn.metrics import precision_recall_fscore_support
# Select all non-averaged values from the report
precision_recall_fscore_support(y_true,predicted_values)
cr_loan_prep 資料集與 preds_df 中的預測結果都已經載入到工作區了。
本練習屬於課程
以 Python 進行信用風險建模
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Print the classification report
target_names = ['Non-Default', 'Default']
print(____(____, ____[____], target_names=target_names))