使用 ROC 比較模型
你應該使用 ROC 圖與 AUC 分數來比較兩個模型。有時候,圖像化能大幅幫助你與潛在的商業使用者理解各個候選模型之間的差異。
有了圖表作為依據,你會更有把握做出決策。Lift 指的是曲線相對於隨機預測的距離;AUC 則是曲線與隨機預測之間的面積。Lift 較大且 AUC 較高的模型,通常能更精準地進行預測。
已將訓練完成的模型 clf_logistic 與 clf_gbt 載入到工作區。同時也載入了違約機率的預測值 clf_logistic_preds 與 clf_gbt_preds。
本練習屬於課程
以 Python 進行信用風險建模
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# ROC chart components
fallout_lr, sensitivity_lr, thresholds_lr = ____(____, ____)
fallout_gbt, sensitivity_gbt, thresholds_gbt = ____(____, ____)
# ROC Chart with both
plt.plot(____, ____, color = 'blue', label='%s' % 'Logistic Regression')
plt.plot(____, ____, color = 'green', label='%s' % 'GBT')
plt.plot([0, 1], [0, 1], linestyle='--', label='%s' % 'Random Prediction')
plt.title("ROC Chart for LR and GBT on the Probability of Default")
plt.xlabel('Fall-out')
plt.ylabel('Sensitivity')
plt.legend()
plt.show()