plot.predx: Draw diagnostic plots and plots for predictions.

View source: R/plotting.R

plot.predxR Documentation

Draw diagnostic plots and plots for predictions.

Description

Generates diagnostic plots of residuals or plots of fitted versus outcome as appropriate for the particular prediction type and displays prediction type-specific analysis results.

Usage

## S3 method for class 'predx'
plot(
  x,
  type = c("diagnostic", "fit", "regression", "roc", "confusion", "class_p",
    "class_stats"),
  plot_title = NULL,
  plot_subtitle = NULL,
  plot_tag = NULL,
  signif_digits = 2,
  cust_theme = ggplot2::theme_classic(),
  ...
)

## S3 method for class 'caretx'
plot(
  x,
  newdata = NULL,
  type = c("diagnostic", "fit", "regression", "roc", "confusion", "performance",
    "class_p", "class_stats"),
  plot_title = NULL,
  plot_subtitle = NULL,
  plot_tag = NULL,
  signif_digits = 2,
  cust_theme = ggplot2::theme_classic(),
  ...
)

Arguments

x

a caretx model or predx prediction object.

type

type of the plot:

  • diagnostic: diagnostic plots of residuals

  • fit: the fitted versus outcome plot specific for the prediction character (scatter plot for regression, ROC for binary classification and heat map of the confusion matrix for multi-class prediction)

  • regression: scatter plot of the fitted vs outcome values

  • roc: receiver-operating characteristic (ROC) plot

  • confusion: heat map representation of the confusion matrix.

  • performance: a scatter plot with model performance stats in the test, resample (CV) and, optionally, training data set. See: plot_performance for details.

  • class_p: a list of scatter plots with square distances to the outcome (Brier et al.) and class-assignment probabilities. By default, misclassified observations are labeled. See: plot_class_p for details.

  • class_stats: a list of box plots with square distances to the outcome (Brier et al.) and class-assignment probabilities. See: plot_class_stats for details.

plot_title

predx: plot title; caretx: a vector with plot titles, length 2 if no newdata provided, otherwise length 3.

plot_subtitle

plot subtitle. If not specified by the user, the sub-title displays statistics specific for the prediction type.

plot_tag

plot tag, number of complete observations and events if not specified otherwise by the user.

signif_digits

significant digits used for rounding of statistic values presented in the plot.

cust_theme

customized plot theme provided by the user.

...

extra arguments passed to plotting functions, as specified by the plot type:

  • diagnostic: get_qc_plots

  • regression: plot_regression

  • roc: plot_roc

  • confusion: plot_confusion

  • performance: plot_performance

  • class_p: plot_class_p

  • class_stats: plot_class_stats

newdata

an optional test data set.

Value

a ggplot graphic with the requested content (predx) or a list of ggplot graphics (caretx, except for performance plot type).

References

Kuhn M. Building predictive models in R using the caret package. J Stat Softw (2008) 28:1–26. doi:10.18637/jss.v028.i05

Brier GW. VERIFICATION OF FORECASTS EXPRESSED IN TERMS OF PROBABILITY. Mon Weather Rev (1950) 78:1–3. doi:10.1175/1520-0493(1950)078<0001:vofeit>2.0.co;2

Goldstein-Greenwood J. A Brief on Brier Scores | UVA Library. (2021) Available at: https://library.virginia.edu/data/articles/a-brief-on-brier-scores

Cohen J. A Coefficient of Agreement for Nominal Scales. Educ Psychol Meas (1960) 20:37–46. doi:10.1177/001316446002000104


PiotrTymoszuk/caretExtra documentation built on Oct. 15, 2023, 10:03 p.m.