predict-methods: Model predictions for familiar models and model ensembles

predictR Documentation

Model predictions for familiar models and model ensembles

Description

Fits the model or ensemble of models to the data and shows the result.

Usage

predict(object, ...)

## S4 method for signature 'familiarModel'
predict(
  object,
  newdata,
  type = "default",
  time = NULL,
  dir_path = NULL,
  ensemble_method = "median",
  stratification_threshold = NULL,
  stratification_method = NULL,
  percentiles = NULL,
  ...
)

## S4 method for signature 'familiarEnsemble'
predict(
  object,
  newdata,
  type = "default",
  time = NULL,
  dir_path = NULL,
  ensemble_method = "median",
  stratification_threshold = NULL,
  stratification_method = NULL,
  percentiles = NULL,
  ...
)

## S4 method for signature 'familiarNoveltyDetector'
predict(object, newdata, type = "novelty", ...)

## S4 method for signature 'list'
predict(
  object,
  newdata,
  type = "default",
  time = NULL,
  dir_path = NULL,
  ensemble_method = "median",
  stratification_threshold = NULL,
  stratification_method = NULL,
  percentiles = NULL,
  ...
)

## S4 method for signature 'character'
predict(
  object,
  newdata,
  type = "default",
  time = NULL,
  dir_path = NULL,
  ensemble_method = "median",
  stratification_threshold = NULL,
  stratification_method = NULL,
  percentiles = NULL,
  ...
)

Arguments

object

A familiar model or ensemble of models that should be used for prediction. This can also be a path to the ensemble model, one or more paths to models, or a list of models.

...

to be documented.

newdata

Data to which the models are fitted. familiar performs checks on the data to ensure that all features required for fitting the model are present, and no additional levels are present in categorical features. Unlike other predict methods, newdata cannot be missing in familiar, as training data are not stored with the models.

type

Type of prediction made. The following values are directly supported:

  • default: Default prediction, i.e. value estimates for count and continuous outcomes, predicted class probabilities and class for binomial and multinomial and the model response for survival outcomes.

  • survival_probability: Predicts survival probabilities at the time specified by time. Only applicable to survival outcomes. Some models may not allow for predicting survival probabilities based on their response.

  • novelty: Predicts novelty of each sample, which can be used for out-of-distribution detection.

  • risk_stratification: Predicts the strata to which the data belongs. Only for survival outcomes.

Other values for type are passed to the fitting method of the actual underlying model. For example for generalised linear models (glm) type can be link, response or terms as well. Some of these model-specific prediction types may fail to return results if the model has been trimmed.

time

Time at which the response (default) or survival probability (survival_probability) should be predicted for survival outcomes. Some models have a response that does not depend on time, e.g. cox, whereas others do, e.g. random_forest.

dir_path

Path to the folder containing the models. Ensemble objects are stored with the models detached. In case the models were moved since creation, dir_path can be used to specify the current folder. Alternatively the update_model_dir_path method can be used to update the path.

ensemble_method

Method for ensembling predictions from models for the same sample. Available methods are:

  • median (default): Use the median of the predicted values as the ensemble value for a sample.

  • mean: Use the mean of the predicted values as the ensemble value for a sample.

stratification_threshold

Threshold value(s) used for stratifying instances into risk groups. If this parameter is specified, stratification_method and any threshold values that come with the model are ignored, and stratification_threshold is used instead.

stratification_method

Selects the stratification method from which the threshold values should be selected. If the model or ensemble of models does not contain thresholds for the indicated method, an error is returned. In addition this argument is ignored if a stratification_threshold is set.

percentiles

Currently unused.

Details

This method is used to predict values for instances specified by the newdata using the model or ensemble of models specified by the object argument.

Value

A data.table with predicted values.


familiar documentation built on Sept. 30, 2024, 9:18 a.m.