評估模型效能

使用 R 進行網路化資料的預測分析

María Óskarsdóttir, Ph.D.

Post-doctoral researcher

進行預測

library(pROC)
  • 邏輯斯回歸
logPredictions <- predict(logModel, newdata = test_set, type = "response")
  • 隨機森林
rfPredictions<- predict(rfModel, newdata = test_set, type='prob')
rfPredictions
attr(,"class")
      0     1
C 0.136 0.864
"matrix" "votes"
使用 R 進行網路化資料的預測分析

AUC

  • 隨機抽到的流失客分數高於隨機抽到的非流失客的機率。
  • 顯示模型靈敏度與特異度的權衡。
  • 數值介於:
    • 0.5:隨機模型
    • 1:完美模型
library(pROC)
auc(test_set$label, logPredictions)
使用 R 進行網路化資料的預測分析

前十分位 lift

  • 預測模型辨識流失客的能力,比隨機抽樣好多少。
  • 計算在預測流失機率最高的前 10% 客戶中,實際流失者所占比例{{1}}。
  • Lift 大於 1 代表模型優於隨機模型{{2}}。
  • 若最高分數的前 10% 中有 60% 為流失客,且全體人口中有 10% 為流失客,則 lift 為 $60/10=6$
library(lift)
TopDecileLift(test_set$label, predictions, plot=TRUE)
使用 R 進行網路化資料的預測分析

一起來練習吧!

使用 R 進行網路化資料的預測分析

Preparing Video For Download...