Learn R Programming

datarobot (version 2.18.6)

Predict: Retrieve model predictions

Description

This function can be used to predict with a particular model.

Usage

Predict(
  model,
  predictionDataset,
  classPrefix = "class_",
  maxWait = 600,
  forecastPoint = NULL,
  predictionsStartDate = NULL,
  predictionsEndDate = NULL,
  type = "response",
  includePredictionIntervals = FALSE,
  predictionIntervalsSize = NULL
)

Value

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

Arguments

model

An S3 object of class dataRobotModel like that returned by the function GetModel, or each element of the list returned by the function ListModels.

predictionDataset

object. Either a dataframe of data to predict on or a DataRobot prediction dataset object of class dataRobotPredictionDataset.

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.

forecastPoint

character. Optional. The point relative to which predictions will be generated, based on the forecast window of the project. Only specified in time series projects.

predictionsStartDate

datetime. Optional. Only specified in time series projects. The start date for bulk predictions. Note that this parameter is for generating historical predictions using the training data. This parameter should be provided in conjunction predictionsEndDate. Can't be provided with forecastPoint parameter.

predictionsEndDate

datetime. Optional. Only specified in time series projects. The end date for bulk predictions. Note that this parameter is for generating historical predictions using the training data. This parameter should be provided in conjunction predictionsStartDate. Can't be provided with forecastPoint parameter.

type

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

includePredictionIntervals

logical. Optional. Should prediction intervals bounds should be part of predictions? Only available for time series projects. See "Details" for more info.

predictionIntervalsSize

numeric. Optional. Size of the prediction intervals, in percent. Only available for time series projects. See "Details" for more info.

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.

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

See RequestPredictions and GetPredictions for more details.

Examples

Run this code
if (FALSE) {
   trainIndex <- sample(nrow(iris) * 0.7)
   trainIris <- iris[trainIndex, ]
   testIris <- iris[-trainIndex, ]
   project <- StartProject(trainIris, "iris", target = "Petal_Width", wait = TRUE)
   model <- GetRecommendedModel(project)
   predictions <- Predict(model, testIris)

   # Or, if prediction intervals are desired (datetime only)
   model <- GetRecommendedModel(datetimeProject)
   predictions <- Predict(model,
                          dataset,
                          includePredictionIntervals = TRUE,
                          predictionIntervalsSize = 100,
                          type = "raw")
}

Run the code above in your browser using DataLab