GetPredictionExplanationsRowsAsDataFrame: Retrieve all prediction explanations rows and return them as...

View source: R/PredictionExplanations.R

GetPredictionExplanationsRowsAsDataFrameR Documentation

Retrieve all prediction explanations rows and return them as a data frame

Description

There are some groups of columns whose appearance depends on the exact contents of the project dataset. For classification projects, columns "classNLabel", 'classNProbability", "classNLabel", "classNProbability" will appear corresponding to each class within the target; these columns will not appear for regression projects. Columns like "explanationNLabel" will appear corresponding to each included prediction explanation in the row. In both cases, the value of N will start at 1 and count up.

Usage

GetPredictionExplanationsRowsAsDataFrame(
  project,
  predictionExplanationId,
  excludeAdjustedPredictions = TRUE,
  batchSize = NULL
)

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.

predictionExplanationId

character. Id of the prediction explanations.

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.

batchSize

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

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]]
  datasetId <- dataset$id
  model <- GetModel(projectId, modelId)
  jobId <- RequestPredictionExplanations(model, datasetId)
  predictionExplanationId <- GetPredictionExplanationsMetadataFromJobId(projectId, jobId)$id
  GetPredictionExplanationsRowsAsDataFrame(projectId, predictionExplanationId)

## End(Not run)

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