trainer <- function(training, testing){
trControl <- trainControl(method="cv", number=5)
modelFit <- train(training$classe ~ ., method="rf", preProcess="pca",
trControl=trControl, data=training)
confMatrix <- confusionMatrix(testing$classe, predict(modelFit,testing))
output <- list(modelFit, confMatrix)
return(output)
}
The returned value is supposed to be a model, modelFit
, which isn't a list, But when I check class(output[1])
, it reports as a list. Seems somehow the model file is converted to a list. How to retain the original data type without converting it a list, because I need to access the model file in the return.