Skip to contents

Visualizations rpart trees using the package ggparty.

Usage

# S3 method for LearnerClassifRpart
autoplot(object, theme = theme_minimal(), ...)

# S3 method for LearnerRegrRpart
autoplot(object, theme = theme_minimal(), ...)

Arguments

object

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

theme

(ggplot2::theme())
The ggplot2::theme_minimal() is applied by default to all plots.

...

(ignored).

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)
}