components.caretx: Access features and statistics of models and predictions

View source: R/extraction.R

components.caretxR Documentation

Access features and statistics of models and predictions

Description

The components() and model.frame() methods provide handy extractor functions enabling access to the data, predictions, number of observations and fit summary.

Usage

## S3 method for class 'caretx'
components(
  object,
  newdata = NULL,
  what = c("data", "formula", "resample", "tuning", "best_tune", "prediction",
    "probability", "square_dist", "fit", "n", "n_classes", "residuals", "confusion"),
  ...
)

## S3 method for class 'predx'
components(
  object,
  what = c("data", "prediction", "classes", "probability", "square_dist", "fit", "n",
    "n_classes", "residuals", "confusion"),
  ...
)

## S3 method for class 'predx'
model.frame(formula, ...)

## S3 method for class 'caretx'
model.frame(formula, ...)

Arguments

object

a caretx model or predx prediction object.

newdata

test data set required for making predictions. NULL by default, used only if what is set to prediction.

what

name of the requested feature:

  • data: the training data (caretx) or predictions (predx)

  • formula: the model's formula

  • resample: a data frame with tuning fit stats in the model's resamples (e.g. CV folds)

  • tuning: a data frame with tuning results.

  • best_tune: the combination of tuning parameters for the model with the optimal performance in the resamples.

  • prediction: the predictions, optionally for the test data provides as the newdata argument

  • fit: returns statistics of the model fit

  • classes: returns the outcome class vector

  • probability: a data frame or a list of data frames with class assignment probability

  • square_dist: squared distance from the outcome as defined by Brier at al.

  • n: the complete case number

  • n_classes: number of observations in the true outcome and fitted classes. NULL for regression models.

  • residuals: model fit residuals

  • confusion: computes the confusion matrix with observation counts

...

additional arguments passed to the specific methods.

formula

caretx model or predx prediction object.

Value

the requested feature.

References

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


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