Skip to content
Prev 344793 / 398500 Next

Help with caret, please

Hello,

I am using caret package in order to train a K-Nearest Neigbors algorithm. For this, I am running this code:

Control <- trainControl(method="cv", summaryFunction=twoClassSummary, classProb=T)

tGrid=data.frame(k=1:100)

trainingInfo <- train(Formula, data=trainData, method = "knn",tuneGrid=tGrid,
                              trControl=Control, metric =  "ROC")
As you can see, I am interested in obtain the AUC parameter of the ROC. This code works good but returns the testing error (which the algorithm uses for tuning the k parameter of the model) as the mean of the error of the CrossValidation folds. I am interested in return, in addition of the testing error, the trainingerror (the mean across each fold of the error obtained with the training data). ?How can I do it? 

Thank you