以下是我使用交叉验证方法运行KNN模型的脚本。
## cross validation
library(caret)
cvroc <- trainControl(method = "repeatedcv",
number = 10, # number of iteration
repeats = 3,
classProbs = TRUE,
summaryFunction = twoClassSummary)
#KNN Model
set.seed(222)
fit_roc <- train(admit ~. ,
data = training,
method = 'knn',
tuneLength = 20,
trControl = cvroc, .
preProc = c("center","scale"),
metric = "ROC",
tuneGrid =expand.grid(k=1:60))
fit_roc
问题: 我的问题是,如何将模型的输出转换为data.frame? 我用下面的命令给出了错误。
aa <- data.frame(fit_roc)
谢谢!
答案 0 :(得分:0)
根据所需的输出部分,可以执行以下操作:指向fit_roc$whatever you want to extract
fit_roc$results