GetPredictions {datarobot}R Documentation

Retrieve model predictions

Description

This function can be used to retrieve predictions from a project and either (1) a predictionId specifying the ID for the predictions desired (use ListPredictions to see available predictionIds for individual prediction sets) or (2) a predictionJobId that comes from a call to RequestPredictions. This function will then return the predictions generated for the model and data.

Usage

GetPredictions(
  project,
  predictId,
  type = "response",
  classPrefix = "class_",
  maxWait = 600
)

Arguments

project

character. Either (1) a character string giving the unique alphanumeric identifier for the project, or (2) a list containing the element projectId with this identifier.

predictId

character or integer. Either can be the character id of the predictionId associated with the prediction or the integer predictionJobId that is created by the call to RequestPredictions.

type

character. String specifying the type of response for binary classifiers; see Details.

classPrefix

character. For multiclass projects returning prediction probabilities, this prefix is prepended to each class in the header of the dataframe. Defaults to "class_".

maxWait

integer. The maximum time (in seconds) to wait for the prediction job to complete.

Details

The contents of the return vector depends on the modeling task - binary classification, multiclass classification, or regression; whether or not the underlying data is time series, multiseries, cross-series, or not time series; and the value of the 'type' parameter. For non-time-series regression tasks, the type parameter is ignored and a vector of numerical predictions of the response variable is returned.

For binary classification tasks, either a vector of predicted responses is returned if type has the value response (the default), or a vector of probabilities for the positive class is returned, if type is probability. You can also fetch the raw dataframe of prediction values using raw.

For multiclass classification tasks, response will return the predicted class and probability will return the probability of each class.

For time series tasks, 'type = "raw"' will return more detailed information on the time series prediction. This will also include any prediction intervals if requested.

This function will error if the requested job has errored or if it has not completed within maxWait seconds.

Value

Vector of predictions, depending on the modeling task ("Binary", "Multiclass", or "Regression") and the value of the type parameter; see Details.

Examples

## Not run: 
  # Retrieve by predictJobID
  dataset <- UploadPredictionDataset(project, diamonds_small)
  model <- ListModels(project)[[1]]
  modelId <- model$modelId
  predictJobId <- RequestPredictions(project, modelId, dataset$id)
  predictions <- GetPredictions(project, predictJobId)
  # Retrieve by predictionID
  predictions <- ListPredictions(project)
  predictions <- GetPredictions(project, predictions$predictionId[[1]])

## End(Not run)

[Package datarobot version 2.18.6 Index]