Reputation: 620
I am using caret package to train my model.
My model is working fine. But when I plot the decision tree, the labels are blank. How do i get the labels?
carMod <- train( FLAG ~.,data=df_train, method="rpart" )
plot(carMod$finalModel)
Upvotes: 3
Views: 3528
Reputation: 1016
Use the following code, as explained on the help page for plot.rpart
(https://stat.ethz.ch/R-manual/R-devel/library/rpart/html/plot.rpart.html):
plot(carMod$finalModel)
text(carMod$finalModel)
Alternatively use
library(rpart.plot)
rpart.plot(carMod$finalModel)
For more information, see https://blog.revolutionanalytics.com/2013/06/plotting-classification-and-regression-trees-with-plotrpart.html
Upvotes: 0