GetPredictionExplanations: Get prediction explanations

View source: R/PredictionExplanations.R

GetPredictionExplanationsR Documentation

Get prediction explanations

Description

A streamlined workflow to both generate and retrieve prediction explanations for a model.

Usage

GetPredictionExplanations(
  model,
  dataset,
  maxExplanations = NULL,
  thresholdLow = NULL,
  thresholdHigh = NULL,
  batchSize = NULL,
  maxWait = 600,
  excludeAdjustedPredictions = TRUE
)

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.

dataset

object. Either (1) the prediction dataset object of class dataRobotPredictionDataset, (2) a data.frame containing the prediction data, (3) the datasetID of the prediction dataset, (4) a file path to the data, or (5) a URL to the data. References the dataset of predictions used to get prediction explanations for.

maxExplanations

integer. Optional. The maximum number of prediction explanations to supply per row of the dataset, default: 3.

thresholdLow

numeric. Optional. The lower threshold, below which a prediction must score in order for prediction explanations to be computed for a row in the dataset. If neither threshold_high nor threshold_low is specified, prediction explanations will be computed for all rows.

thresholdHigh

numeric. Optional. The high threshold, above which a prediction must score in order for prediction explanations to be computed. If neither threshold_high nor threshold_low is specified, prediction explanations will be computed for all rows.

batchSize

integer. Optional. Maximum number of prediction explanations rows to retrieve per request

maxWait

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

excludeAdjustedPredictions

logical. Optional. Set to FALSE to include adjusted predictions, which are predictions adjusted by an exposure column. This is only relevant for projects that use an exposure column.

Value

data frame with following columns:

  • rowId integer. Row id from prediction dataset.

  • prediction numeric. The output of the model for this row (numeric prediction for regression problem, predicted class for classification problem).

  • class1Label character. Label of class 0. Available only for classification problem.

  • class1Probability numeric. Predicted probability of class 0. Available only for classification problem.

  • class2Label character. Label of class 1. Available only for classification problem.

  • class2Probability numeric. Predicted probability of class 1. Available only for classification problem.

  • explanation1FeatureName character. The name of the feature contributing to the prediction.

  • explanation1FeatureValue character. the value the feature took on for this row.

  • explanation1QualitativeStrength numeric. How strongly the feature affected the prediction.

  • explanation1Strength character. A human-readable description of how strongly the feature affected the prediction (e.g. '+++', '–', '+').

  • explanation1Label character. Describes what output was driven by this prediction explanation. For regression projects, it is the name of the target feature. For classification projects, it is the class whose probability increasing would correspond to a positive strength of this.

  • explanationNFeatureName character. The name of the feature contributing to the prediction.

  • explanationNFeatureValue character. The value the feature took on for this row.

  • explanationNQualitativeStrength numeric. How strongly the feature affected the prediction.

  • explanationNStrength character. A human-readable description of how strongly the feature affected the prediction (e.g. '+++', '–', '+').

  • explanationNLabel character. Describes what output was driven by this prediction explanation. For regression projects, it is the name of the target feature. For classification projects, it is the class whose probability increasing would correspond to a positive strength of this.

  • explanationNFeatureName. Character string the name of the feature contributing to the prediction.

Examples

## Not run: 
  projectId <- "59a5af20c80891534e3c2bde"
  modelId <- "5996f820af07fc605e81ead4"
  datasets <- ListPredictionDatasets(projectId)
  dataset <- datasets[[1]]
  model <- GetModel(projectId, modelId)
  GetPredictionExplanations(model, dataset)

## End(Not run)

datarobot documentation built on Nov. 3, 2023, 1:07 a.m.