# R语言利用ROCR评测模型的预测能力

#### 操作

library(caret)
data(churn)

str(churnTrain)

churnTrain = churnTrain[,!names(churnTrain) %in% c("state","area_code","account_length")]

#生成随机编号为2的随机数
set.seed(2)
#将churnTrain的数据集分为两类，按0.7与0.3的比例无放回抽样
ind = sample(2,nrow(churnTrain),replace = TRUE,prob = c(0.7,0.3))

trainset = churnTrain[ind == 1,]
testset = churnTrain[ind == 2,]

library(gplots)
ibrary(ROCR)
library(e1071)

svmfit = svm(churn ~ .,data = trainset,prob = TRUE)


Pred = predict(svmfit,testset[,!names(testset) %in% c("churn")],probability = TRUE )

pred.prob = attr(pred,"probabilities")
pred.to.roc = pred.prob[,2]

pred.rocr = prediction(pred,testset\$churn)

pred.rocr.pref = performance(pred.rocr,"tpr","fpr")
pred.rocr.auc.perf = performance(pred.rocr,measure = "auc",x.measure = "cutoff")
plot(pred.rocr.pref,col = 2,colorize=T,main=paste("AUC:",pred.rocr.auc.perf@y.values))

#### 用R软件包ROCR画ROC曲线

2017-04-19 16:56:42

#### ROCR资料备忘:画带颜色区分的多条ROC曲线图

2017-02-22 21:23:47

#### R语言|求ROC和AUC值

2016-09-29 15:36:54

#### R语言-绘制ROC曲线

2016-04-14 21:28:35

#### 机器学习模型评价指标及R实现

2016-06-10 22:32:34

#### R语言之模型评估

2017-06-07 17:25:39

#### 机器学习实战：模型评估和优化

2016-02-03 20:34:04

#### R语言做评分卡模型<一>

2018-01-09 11:16:24

#### 完整的R语言预测建模实例-从数据清理到建模预测

2016-09-23 16:17:30

#### R+OCR︱借助tesseract包实现图片文本提取功能

2017-01-15 10:39:08