if (FALSE) {
library(mlbench)
library(rpart)
library(treemisc)
# Generate training data from the twonorm benchmark problem
set.seed(1050) # for reproducibility
trn <- as.data.frame(mlbench.twonorm(500, d = 2))
# Fit a default classification tree
tree <- rpart(classes ~ ., data = trn)
# Scatterplot of training data
palette("Okabe-Ito")
plot(x.2 ~ x.1, data = trn, col = as.integer(trn$classes) + 1,
xlab = expression(x[1]), ylab = expression(x[2]))
palette("default")
# Add a decision boundary
decision_boundary(tree, train = trn, y = "y", x1 = "x.1", x2 = "x.2")
}
Run the code above in your browser using DataLab