Question: Use the rpart function in R to creat a decision tree model for the Insurance Category dependent variable. Do not forget to load library(rpart). Provide

  1. Use the rpart function in R to creat a decision tree model for the Insurance Category dependent variable. Do not forget to load library(rpart). Provide evidence in Word that you have created the model.
  2. Using summary(), identify the three most important independent variables used to predict Insurance Category. In Word, show evidence of the three top independent variables. Writ a short explanation of your findings.
  3. Use Tools > Install Packages in the R Studio application menu to install the rpart.plot package. Once installed, load this package using library(rpart.plot). Then, use the prp function to visualize your decision tree. You may need to resize the Plots window in the lower right part of your R Studio application to make the tree large enough to read. In your prp function, include the following parameters: extra=4, faclen=0, varlen=0, cex=.75. The extra parameter includes the confidence percentages in each leaf of your tree; faclen causes the independent variable names to be spelled out in the tree; varlen causes the dependent variable values to be spelled out in the tree, and cex sets the font size (you can experiment with this if you would like). In your Word document, include a screen capture of your visualized decision tree. Writ a short explanation of how the percentages in each tree leaf would be interpreted.
  4. Make predictions for each of the policy buyers by applying your decision tree model the Policy Buyers data set. When using the predict function in R, be sure to include the parameter type="class" so that you will generate an Insurance Category for each policy buyer. Using the Filter feature in R Studio, report the number of policy buyers that you predict will fall into each of the four categories. Be sure to label these clearly in your Word document. If you have done this step correctly, the numbers predicted for each category should total to 473, which is the number of records in the Policy Buyers data set.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!