评估模型性能

使用 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 进行网络数据的预测分析

前十分位提升(Top decile lift)

  • 预测模型识别流失用户相较于随机抽样有多大提升
  • 计算在预测流失概率最高的前10%客户中,实际流失者所占比例
  • 提升值大于1表示模型优于随机模型
  • 若最高分前10%中有60%流失者,而整体人群为10%流失,则提升为$60/10=6$
library(lift)
TopDecileLift(test_set$label, predictions, plot=TRUE)
使用 R 进行网络数据的预测分析

开始练习!

使用 R 进行网络数据的预测分析

Preparing Video For Download...