# Intermediate Tree 2

**R-exercises**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This is a continuation of the intermediate decision tree exercise.

Answers to the exercises are available here.

If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.

**Learn more**about decisions tree’s in the online courses Regression Machine Learning with R and Machine Learning A-Z™: Hands-On Python & R In Data Science

**Exercise 1**

use the `predict()`

command to make predictions on the Train data. Set the method to “class”. Class returns classifications instead of probability scores. Store this prediction in pred_dec.

**Exercise 2**

Print out the confusion matrix

**Exercise 3**

What is the accuracy of the model. Use the confusion matrix.

**Exercise 4**

What is the misclassification error rate? Refer to Basic_decision_tree exercise to get the formula.

**Exercise 5**

Lets say we want to find the baseline model to compare our prediction improvement. We create a base model using this code

```
length(Test$class)
base=rep(1,3183)
```

Use the table() command to create a confusion matrix between the base and Test$class

**Exercise 6**

What is the number difference between the confusion matrix accuracy of dec and base?

**Exercise 7**

Remember the predict() command in question 1. We will use the same mode and same command except we will set the method to “regression”. This gives us a probability estimates. Store this in pred_dec_reg

**Exercise 8**

load the ROCR package.

Use the prediction(), performance() and plot() command to print the ROC curve. Use pred_dec_reg variable from Q7. You can also refer to the previous exercise to see the code.

**Exercise 9**

plot() the same ROC curve but set colorize=TRUE

**Exercise 10**

Comment on your findings using ROC curve and accuracy. Is it a good model? Did you notice that ROC prediction() command only takes probability predictions as one of its arguments. Why is that so?

**leave a comment**for the author, please follow the link and comment on their blog:

**R-exercises**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.