I trained Decision Tree model using train function from caret library:
gr = expand.grid(trials = c(1, 10, 20), model = c("tree", "rules"), winnow = c(TRUE, FALSE))
dt = train(y ~ ., data = train, method = "C5.0", trControl = trainControl(method = 'cv', number = 10), tuneGrid = gr)
Now I would like to plot Decision Tree for the final model. But this command doesn't work:
plot(dt$finalModel)
Error in data.frame(eval(parse(text = paste(obj$call)[xspot])), eval(parse(text = paste(obj$call)[yspot])), :
arguments imply differing number of rows: 4160, 208, 0
Someone already asked about it here: topic
Suggested solution was to use bestTune from the fitted train object to define the relevant c5.0 model manually. And then plot that c5.0 model normally:
c5model = C5.0(x = x, y = y, trials = dt$bestTune$trials, rules = dt$bestTune$model == "rules", control = C5.0Control(winnow = dt$bestTune$winnow))
plot(c5model)
I tried to do so. Yes, it makes possible to plot c5.0 model, BUT predicted probabilities from train object and manually recreated c5.0 model don't match.
So, my question is: is it possible to extract final c5.0 model from caret::train object and plot this Decision Tree?