Now that we have trained a decision tree model, we need to extract the insights from the model. In this section, we are going to use a library called rattle:
- You can install this package by using the following command in your RStudio:
install.packages("rattle")
- Once you have installed this library correctly, you should be able to import the library as follows:
library(rattle)
- Once you have set up your R environment with this new library, rattle, it requires just one line of code to visualize the trained decision tree. Take a look at the following code:
fancyRpartPlot(fit)
- As you can see, the fancyRpartPlot function takes in an rpart model object. Here, the model object, fit, is the decision tree model that ...