Search code examples
rr-caretpmml

Caret Model how to train the final model using optimized parameters?


train_control <- trainControl(method='cv', number=10)    
model <- train(Class ~ Age+BMI+DBP+DPF+NumPregnancies+PG2+SI2+TSFT, method ='rf',data=input,trControl=train_control)

pmml(model$finalModel)
#Error in names(field$class) <- var.names : attempt to set an attribute on NULL

When I try to export the caret trained RF model to PMML, It fails. Is there a method to run RF manually using the optimal parameters tuned by caret package so that I can export the model to PMML?


Solution

  • Tuned Parameters can be accessed through model$bestTune

    > model$bestTune
    mtry
    3   23