[R] Help with caret, please

Iván Vallés Pérez ivanvallesperez at gmail.com
Sun Oct 12 01:58:11 CEST 2014


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
	[[alternative HTML version deleted]]



More information about the R-help mailing list