赞
踩
#logistic- caret::train
#划分数据集
set.seed(123)
folds <- createFolds(y=data$Groups,k=10)
# 建一个放auc值的空向量 auc<-as.numeric() Errorrate<-as.numeric() accuracy<-as.numeric() sensitivity<-as.numeric() specificity<-as.numeric() roc <- vector("list", 10) #设置交叉验证参数 set.seed(123) #使结果具有可重复性 trainControl<- trainControl(method = "cv", number = 10) for(i in 1:10){ test <- data[folds[[i]],] train <- data[-folds[[i]],] logit<- caret::train(Groups ~ ., data = train, family = binomial(link = "logit"), trainControl= trainControl #linout = FALSE, #trace = FALSE ) #预测 pred <- predict(logit, newdata = test, probability = TRUE) prob <- predict(logit, newdata = test, type = "prob")[,2] #混淆矩阵 table<-table(Predicted=pre
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。