Skip to contents

Visualize trees for mlr3::mlr_learners_classif.rpart and mlr3::mlr_learners_regr.rpart using the package ggparty.

Contrary to ggparty, boxplots are shown in the terminal nodes for regression trees.

Note that learner-specific plots are experimental and subject to change.

Usage

# S3 method for LearnerClassifRpart
autoplot(object, ...)

# S3 method for LearnerRegrRpart
autoplot(object, ...)

Arguments

object

(mlr3::LearnerClassifRpart | mlr3::LearnerRegrRpart).

...

(any): Additional arguments, passed down to ggparty::autoplot.party().

Value

ggplot2::ggplot() object.

Theme

The theme_mlr3() and viridis color maps are applied by default to all autoplot() methods. To change this behavior set options(mlr3.theme = FALSE).

Examples

if (requireNamespace("mlr3")) {
  library(mlr3)
  library(mlr3viz)

  # classification
  task = tsk("iris")
  learner = lrn("classif.rpart", keep_model = TRUE)
  learner$train(task)
  autoplot(learner)

  # regression
  task = tsk("mtcars")
  learner = lrn("regr.rpart", keep_model = TRUE)
  learner$train(task)
  autoplot(learner)
}