50.1K
Verified Solution
Link Copied!
Wondering how the sketch would look like for the question below.
**QUESTION FROM CHAPTER 8 -QUESTION 9 OF 'An Introduction to Statistical Learning with Applications in R**
2) Sketch the tree (part a), and the partition of the predictor space (part b), by hand.
PART A
```{r} set.seed(1) library(ISLR) train=sample(1:nrow(OJ),800,replace=F) OJtrain=OJ[train,] OJtest=OJ[-train,]
```
PART B
```{r} library(tree) tree.oj=tree(Purchase ~ ., data = OJtrain) summary(tree.oj) ```
PART B OUTCOME
Classification tree: tree(formula = Purchase ~ ., data = OJtrain) Variables actually used in tree construction: [1] "LoyalCH" "PriceDiff" "SpecialCH" "ListPriceDiff" "PctDiscMM" Number of terminal nodes: 9 Residual mean deviance: 0.7432 = 587.8 / 791 Misclassification error rate: 0.1588 = 127 / 800
Answer & Explanation
Solved by verified expert