Making decisions with trees

Supervised Learning in R: Classification

Brett Lantz

Instructor

A decision tree model

Example Tree Structure

Supervised Learning in R: Classification

Decision trees for prediction

Lending Club Online Application

Supervised Learning in R: Classification

Divide-and-conquer

Divide and Conquer Example

Supervised Learning in R: Classification

Divide-and-conquer

Divide and Conquer Example

Supervised Learning in R: Classification

Divide-and-conquer

Divide and Conquer Example

Supervised Learning in R: Classification

The resulting tree

Divide and Conquer Example

Divide and Conquer Example

Supervised Learning in R: Classification

Building trees in R

# building a simple rpart classification tree
library(rpart)
m <- rpart(outcome ~ loan_amount + credit_score, data = loans,
             method = "class")
# making predictions from an rpart tree
p <- predict(m, test_data, type = "class")
Supervised Learning in R: Classification

Let's practice!

Supervised Learning in R: Classification

Preparing Video For Download...