Learn R Programming

datarobot (version 2.14.2)

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")

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. 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. 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.

Details

The contents of the return vector depends on both the modeling task - binary classification, multiclass classification, or regression - and the value of the type parameter. For 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 returned dataframe of prediction metadata using raw.

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

This function will error if the requested job has errored, or if it isn't complete within maxWait seconds.

Examples

Run this code
# NOT RUN {
   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)
# }

Run the code above in your browser using DataLab