用 ROC 曲線比較樹為基礎的模型
現在請你重做先前的練習,不過這次要比較樹為基礎的模型。pROC() 已載入到你的工作環境。樹為基礎方法的 PD 預測已存放在這些物件中:
predictions_undersamplepredictions_priorpredictions_loss_matrixpredictions_weights
本練習屬於課程
R 的信用風險建模
練習說明
- 使用
roc(response, predictor)函式,為各個樹為基礎的方法建立 ROC 物件。 - 用前一步建立的物件繪製 ROC 曲線。要把它們畫在同一張圖上,先對
ROC_undersample使用plot()畫出第一條 ROC 曲線,再對其餘三個模型使用lines()加到同一張圖。使用col引數將ROC_prior的曲線設為藍色、ROC_loss_matrix為紅色、ROC_weights為綠色。 - 為了更了解 ROC 曲線的表現,使用
auc()函式查看 AUC。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Construct the objects containing ROC-information
ROC_undersample <-
ROC_prior <-
ROC_loss_matrix <-
ROC_weights <-
# Draw the ROC-curves in one plot
# Compute the AUCs