Jimmy Wong
Jimmy Wong

Reputation: 17

R programming - How to convert model output into data frame

below are my scripts in running KNN model using cross validate method.

## 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

KNN model output

Question: My question will be, how can i convert the output from the model into a data.frame? i used the command below it gives error.

aa <- data.frame(fit_roc) 

Thanks!

Upvotes: 0

Views: 1229

Answers (1)

NelsonGon
NelsonGon

Reputation: 13319

Depending on which part of the output you want, you can do the following: The point is fit_roc$whatever you want to extract

fit_roc$results

Upvotes: 1

Related Questions