Aan de slagGa gratis aan de slag

Visualizing classification trees

Due to government rules to prevent illegal discrimination, lenders are required to explain why a loan application was rejected.

The structure of classification trees can be depicted visually, which helps to understand how the tree makes its decisions. The model loan_model that you fit in the last exercise is available to use.

Deze oefening maakt deel uit van de cursus

Supervised Learning in R: Classification

Cursus bekijken

Oefeninstructies

  • Type loan_model to see a text representation of the classification tree.
  • Load the rpart.plot package.
  • Apply the rpart.plot() function to the loan model to visualize the tree.
  • See how changing other plotting parameters impacts the visualization by running the supplied command.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Examine the loan_model object


# Load the rpart.plot package


# Plot the loan_model with default settings


# Plot the loan_model with customized settings
rpart.plot(loan_model, type = 3, box.palette = c("red", "green"), fallen.leaves = TRUE)
Code bewerken en uitvoeren