Learn R Programming

⚠️There's a newer version (0.11.0) of this package.Take me there.

mlr3viz

Package website: release | dev

This R package provides visualizations for mlr3 objects such as tasks, predictions, resample results or benchmark results via the autoplot() generic of ggplot2.

Installation

Install the last release from CRAN:

install.packages("mlr3")

Install the development version from GitHub:

remotes::install_github("mlr-org/mlr3viz")

Short Demo

library(mlr3)
library(mlr3viz)

task = tsk("iris")$select(c("Sepal.Length", "Sepal.Width"))
learner = lrn("classif.rpart", predict_type = "prob")
rr = resample(task, learner, rsmp("cv", folds = 3), store_models = TRUE)

# Default plot for task
autoplot(task)

# Advanced resample result prediction plot
autoplot(rr, type = "prediction")

For more examples plots you can have a look at the pkgdown references of the respective functions.

Theming

{mlr3viz} styles all plots with it’s own theme theme_mlr3() (which is heavily influenced by the ggpubr::theme_pubr() theme) and the “viridis” color palette. If you want to use a different theme or color palette, apply it after the autoplot() call as in

autoplot(<object>) +
  scale_color_discrete() +
  theme_gray()

For color scheme adjustments you might need to change *_color_* to *_fill_* or *_*_discrete to *_*_cotinuous, depending on the object that was visualized.

For even more control, you can look up the source code which ggplot2 geoms were used internally for a specific autoplot() call (e.g. geom_point()) and how they were called. You can then apply these lines again with different arguments after the autoplot() call (similar as shown above with the theme_gray() adjustment) to overwrite their appearance (for example point size, line width, etc.).

Copy Link

Version

Install

install.packages('mlr3viz')

Monthly Downloads

5,171

Version

0.5.8

License

LGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Michel Lang

Last Published

April 4th, 2022

Functions in mlr3viz (0.5.8)

autoplot.TaskClassif

Plot for Classification Tasks
autoplot.ResampleResult

Plot for ResampleResult
autoplot.PredictionSurv

Plot for PredictionSurv
mlr3viz-package

mlr3viz: Visualizations for 'mlr3'
plot_learner_prediction

Plot for Learner Predictions
autoplot.TaskSurv

Plot for Survival Tasks
autoplot.PredictionClassif

Plot for PredictionClassif
autoplot.TuningInstanceSingleCrit

Plot for TuningInstanceSingleCrit
autoplot.TaskRegr

Plot for Regression Tasks
autoplot.TaskDens

Plot for Density Tasks
theme_mlr3

mlr-org ggplot2 theme
autoplot.TaskClust

Plot for Clustering Tasks
predict_grid

Generates a data.table of evenly distributed points.
reexports

Objects exported from other packages
autoplot.LearnerClassifRpart

Plot for LearnerClassifRpart / LearnerRegrRpart
autoplot.OptimInstanceSingleCrit

Plot for OptimInstanceSingleCrit
autoplot.Filter

Plot for Filter Scores
autoplot.BenchmarkResult

Plot for BenchmarkResult
as_precrec

Convert to 'precrec' Format
autoplot.PredictionClust

Plot for PredictionClust
autoplot.LearnerClassifCVGlmnet

Plot for LearnerClassifGlmnet / LearnerRegrGlmnet / LearnerClassifCVGlmnet / LearnerRegrCVGlmnet
autoplot.LearnerClustHierarchical

Plot for Hierarchical Clustering Learners
autoplot.PredictionRegr

Plot for PredictionRegr