autoplot.LearnerClassifRpart: Plots for Rpart Learners

View source: R/LearnerClassifRpart.R

autoplot.LearnerClassifRpartR Documentation

Plots for Rpart Learners

Description

Visualizations rpart trees using the package ggparty.

Usage

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

## S3 method for class '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).

Value

ggplot2::ggplot().

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

mlr3viz documentation built on Nov. 23, 2023, 5:07 p.m.