library(cluster)
library(factoextra)
library(ggplot2)
library(dplyr)
(See Board)
Decision Trees consist of:
Example 1: On the board, one at a time
Question 1 Working with your partner decide on the 4-5 most useful questions you think could be asked in the first round.
Question 2 Working with the group next to you, decide on the 2 most useful questions you think should be asked
Example 2: On the board, one set of 4 at a time.
Question 3 Using the animals dataset from last week, create a tree to classify the animals as efficiently as possible. Note, you should probably write this on paper/whiteboard and take a picture to include. Justify your choices
data("animals")
animals[animals == 1] <- "No"
animals[animals == 2] <- "Yes"
animals <- apply(animals, 2, as.factor)
colnames(animals) <- c("Warm_blooded?", "Can_fly?", "Vertebrate?", "Endangered?", "Lives_in_groups?", "Has_hair?")
rownames(animals) = c("ant","bee","cat","cephalopod", "chimp", "cow", "duck", "eagle", "elephant", "fly", "frog", "hermit", "lion", "lizard", "lobster", "human", "rabbit", "salamander", "spider", "whale")
animals
## Warm_blooded? Can_fly? Vertebrate? Endangered? Lives_in_groups?
## ant "No" "No" "No" "No" "Yes"
## bee "No" "Yes" "No" "No" "Yes"
## cat "Yes" "No" "Yes" "No" "No"
## cephalopod "No" "No" "No" "No" "No"
## chimp "Yes" "No" "Yes" "Yes" "Yes"
## cow "Yes" "No" "Yes" "No" "Yes"
## duck "Yes" "Yes" "Yes" "No" "Yes"
## eagle "Yes" "Yes" "Yes" "Yes" "No"
## elephant "Yes" "No" "Yes" "Yes" "Yes"
## fly "No" "Yes" "No" "No" "No"
## frog "No" "No" "Yes" "Yes" NA
## hermit "No" "No" "Yes" "No" "Yes"
## lion "Yes" "No" "Yes" NA "Yes"
## lizard "No" "No" "Yes" "No" "No"
## lobster "No" "No" "No" "No" NA
## human "Yes" "No" "Yes" "Yes" "Yes"
## rabbit "Yes" "No" "Yes" "No" "Yes"
## salamander "No" "No" "Yes" "No" NA
## spider "No" "No" "No" NA "No"
## whale "Yes" "No" "Yes" "Yes" "Yes"
## Has_hair?
## ant "No"
## bee "Yes"
## cat "Yes"
## cephalopod "Yes"
## chimp "Yes"
## cow "Yes"
## duck "No"
## eagle "No"
## elephant "No"
## fly "No"
## frog "No"
## hermit "No"
## lion "Yes"
## lizard "No"
## lobster "No"
## human "Yes"
## rabbit "Yes"
## salamander "No"
## spider "Yes"
## whale "No"
Much of this is modified from Professor Wells
Predict class rather than value (regression trees)
Metrics are a bit more difficult
Question 7 Work through 8.3.1
In this week we covered Tree based models.