Looking for some help please. I have used the randomForest package extensively and have been happy with its performance. I am currently writing a journal paper investigating match outcomes in sport, predicting the outcome of matches from 33 performance indicators.
I need to use caret to produce the randomForest package as I wish to use Lime to explain outcomes in a testing data set. Lime can't accept a model from randomForest, only from a randomForest wrapped via caret.
When I use random forest I get a prediction accuracy of approx 76% on the training data set, when I tune in caret I get an accuracy of 100%.
Is this sort of improvement common? Or am I making a mistake? Would be really grateful is somebody could check my code.
My data set is named model.data
# Create model with default parameters control <- trainControl(method="repeatedcv", number=10, repeats=3) seed <- 7 metric <- "Accuracy" set.seed(seed) mtry <- sqrt(ncol(model.data)) tunegrid <- expand.grid(.mtry=mtry) rf_group <- train(Outcome~., data=model.data, method="rf", metric=metric, tuneGrid=tunegrid, trControl=control) print(rf_group) # predict the outcome on the training set Test.Predict <- predict(rf_group, model.data) # compare predicted outcome and true outcome confusionMatrix(Test.Predict, as.factor(model.data$Outcome))