Learn R Programming

rtemis (version 1.4.3)

get_predictions: Get predictions

Description

The true and predicted values stored on a fitted supervised model, with the predicted class probabilities of a classifier, one row per case.

Usage

get_predictions(x, sample = NULL, calibrated = FALSE)

Value

data.table with one row per case of each selected sample and the columns sample; resample, the outer resample identifier, for a SupervisedRes model; true; predicted; and, for a classifier, one prob_<class> column per stored probability column: the positive class of a binary classifier, every class of a multiclass one.

Arguments

x

Supervised or SupervisedRes object.

sample

Optional Character {"training", "validation", "test"}: The sample whose predictions to return.

calibrated

Logical: If TRUE, return the calibrated predictions of a calibrated classifier.

Author

EDG

Details

A Supervised model stores predictions for the training sample, and for the validation and test samples when train received dat_validation and dat_test. A SupervisedRes model stores the training and test predictions of each outer resample. The training predictions are the model's fitted values, stats::fitted(). A calibrated classifier also stores its calibrated predictions, selected with calibrated = TRUE.

sample = NULL returns every stored sample, stacked in the order training, validation, test. The samples are the same ones get_metrics() stores metrics for. Requesting a sample the model does not store raises an error that names the samples it does store.

Examples

Run this code
mod <- train(
  iris[1:120, ],
  dat_test = iris[121:150, ],
  hyperparameters = setup_CART(),
  verbosity = 0L
)
head(get_predictions(mod, "test"))

Run the code above in your browser using DataLab