autoplot.PredictionRegr: Plot for PredictionRegr

View source: R/PredictionRegr.R

autoplot.PredictionRegrR Documentation

Plot for PredictionRegr

Description

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

  • "xy" (default): Scatterplot of "true" response vs. "predicted" response. By default a linear model is fitted via geom_smooth(method = "lm") to visualize the trend between x and y (by default colored blue).

    • In addition geom_abline() with slope = 1 is added to the plot.

    • Note that geom_smooth() and geom_abline() may overlap, depending on the given data.

  • "histogram": Histogram of residuals: r = y - y.hat.

  • "residual": Plot of the residuals, with the response y.hat on the "x" and the residuals on the "y" axis.

    • By default a linear model is fitted via geom_smooth(method = "lm") to visualize the trend between x and y (by default colored blue).

Usage

## S3 method for class 'PredictionRegr'
autoplot(object, type = "xy", ...)

Arguments

object

(mlr3::PredictionRegr).

type

(character(1)):
Type of the plot. See description.

...

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

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

library(mlr3)
library(mlr3viz)

task = tsk("boston_housing")
learner = lrn("regr.rpart")
object = learner$train(task)$predict(task)

head(fortify(object))
autoplot(object)
autoplot(object, type = "histogram", binwidth = 1)
autoplot(object, type = "residual")

mlr3viz documentation built on May 25, 2022, 5:06 p.m.