Grant McDermott develop this new R bundle I had considered:
# set up.packages("remotes") remotes::install_github("grantmcdermott/parttree")
Utilizing the acquainted ggplot2 syntax, we will merely add resolution tree boundaries to a plot of our knowledge.
On this instance from his Github web page, Grant trains a choice tree on the well-known Titanic knowledge utilizing the
parsnip bundle. After which visualizes the ensuing partition / resolution boundaries utilizing the straightforward operate
library(parsnip) library(titanic) ## Only for a distinct knowledge set set.seed(123) ## For constant jitter titanic_train$Survived = as.issue(titanic_train$Survived) ## Construct our tree utilizing parsnip (however with rpart because the mannequin engine) ti_tree = decision_tree() %>% set_engine("rpart") %>% set_mode("classification") %>% match(Survived ~ Pclass + Age, knowledge = titanic_train) ## Plot the information and mannequin partitions titanic_train %>% ggplot(aes(x=Pclass, y=Age)) + geom_jitter(aes(col=Survived), alpha=0.7) + geom_parttree(knowledge = ti_tree, aes(fill=Survived), alpha = 0.1) + theme_minimal()
This visualization exactly reveals the place the educated resolution tree thinks it ought to predict that the passengers of the Titanic would have survived (blue areas) or not (purple), based mostly on their
passenger class (Pclass).
This shall be tremendous useful if it is advisable to clarify to your self, your group, or your stakeholders the way you mannequin works. Presently, solely
rpart resolution bushes are supported, however I’m very a lot hoping that Grant continues constructing this performance!