I don't know how to extract the training error (i.e., the error obtained on the training set) using the caret
package in R
. For example, I have the following model:
data(iris);
library(caret);
model<-train(Species~., data=iris, method='knn', trControl=trainControl(method='cv', number=10), tuneGrid=data.frame(k=20))
What I want to do is to see how well the model performed on the training data.
I know I can get the performance on the test set for each fold using model$results
, but that's not what I want. I want to show how the training error is way over-optimistic, but I can't do that. The documentation here:
http://www.inside-r.org/packages/cran/caret/docs/train
states that
results
: a data frame the training error rate and values of the tuning parameters.
which is not true, because in my case, model$results$Accuracy
is always exactly equal to the value of mean(model$resample$Accuracy)
. This is the value of the testing error rate. I want the training eror rate. Is there a way to get it?