autoplot.ResampleResult: Plot for ResampleResult

View source: R/ResampleResult.R

autoplot.ResampleResultR Documentation

Plot for ResampleResult


Generates plots for mlr3::ResampleResult, depending on argument type:

  • "boxplot" (default): Boxplot of performance measures.

  • "histogram": Histogram of performance measures.

  • "roc": ROC curve (1 - specificity on x, sensitivity on y). The predictions of the individual mlr3::Resamplings are merged prior to calculating the ROC curve (micro averaged). Requires package precrec. Additional arguments will be passed down to the respective autoplot() function in package precrec. Arguments calc_avg and cb_alpha are passed to precrec::evalmod().

  • "prc": Precision recall curve. See "roc".

  • "prediction": Plots the learner prediction for a grid of points. Needs models to be stored. Set store_models = TRUE for [mlr3::resample]. For classification, we support tasks with exactly two features and learners with predict_type= set to "response" or "prob". For regression, we support tasks with one or two features. For tasks with one feature we can print confidence bounds if the predict type of the learner was set to "se". For tasks with two features the predict type will be ignored.


## S3 method for class 'ResampleResult'
autoplot(object, type = "boxplot", measure = NULL, predict_sets = "test", ...)





Type of the plot. See description.


Performance measure to use.


Only for type set to "prediction". Which points should be shown in the plot? Can be a subset of ("train", "test") or empty.


(any): Additional arguments, passed down to the respective geom or plotting function.


ggplot2::ggplot() object.


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


Saito T, Rehmsmeier M (2017). “Precrec: fast and accurate precision-recall and ROC curve calculations in R.” Bioinformatics, 33(1), 145-147. doi: 10.1093/bioinformatics/btw570.


if (requireNamespace("mlr3")) {

  task = tsk("sonar")
  learner = lrn("classif.rpart", predict_type = "prob")
  resampling = rsmp("cv")
  object = resample(task, learner, resampling)


  # Default: boxplot

  # Histogram
  autoplot(object, type = "histogram", bins = 30)

  # ROC curve, averaged over resampling folds:
  autoplot(object, type = "roc")

  # ROC curve of joint prediction object:
  autoplot(object$prediction(), type = "roc")

  # Precision Recall Curve
  autoplot(object, type = "prc")

  # Prediction Plot
  task = tsk("iris")$select(c("Sepal.Length", "Sepal.Width"))
  resampling = rsmp("cv", folds = 3)
  object = resample(task, learner, resampling, store_models = TRUE)
  autoplot(object, type = "prediction")

mlr3viz documentation built on Aug. 15, 2022, 5:07 p.m.