Prediction Explanations identify why a given model makes a certain prediction. To calculate Prediction Explanations, use the same endpoint used for calculating bare predictions with the maxExplanations URI parameter set to a positive integer value.
Prediction Explanations can be either:
XEMP-based (the default). To use XEMP-based explanations, first calculate feature impact and initialize Prediction Explanations to provide a qualitative indicator (qualitativeStrength) of the effect variables have on the predictions. Explanations are computed for the top 50 features, ranked by feature impact scores (not including features with zero feature impact).
XEMP- and SHAP-based explanations are mutually exclusive—a model cannot have both XEMP and SHAP explanations. See the Prediction Explanations full documentation for specific calculation information.
Note the following:
SHAP-based explanations are not available for time series or custom models.
Neither XEMP or SHAP explanations are available for images (that is, no Image Explanations).
Performance considerations for XEMP-based explanations
XEMP-based explanations can be 100x slower than regular predictions. Avoid them for low-latency critical use cases. SHAP-based explanations are much faster but can add some latency too.
Multiclass support
Prediction Explanations cannot be generated for XEMP- or SHAP-based multiclass projects.
More information to consider while working with explanations can be found here.
Request Method:POST
Request URL: deployed URL, for example: https://your-company.orm.datarobot.com/predApi/v1.0
A per-organization secret used as an additional authentication factor for prediction servers. Retrieve a datarobot-key programmatically by accessing the /api/v2/predictionServers endpoint. The endpoint returns a URL to a prediction server and a corresponding datarobot-key.
Required for Self-Managed AI Platform users; string type
(deprecated) Basic authentication: User_email and API token
(deprecated) API token
Example for Bearer authentication method: Bearer API_key-12345abcdb-xyz6789
(deprecated) Example for User_email and API token method: Basic Auth_basic-12345abcdb-xyz6789
(deprecated) Example for API token method: Token API_key-12345abcdb-xyz6789
Content-Type
Optional; string type
textplain; charset=UTF-8
text/csv
application/JSON
multipart/form-data (For files with data, i.e., .csv, .txt files)
Content-Encoding
Optional; string type
Currently supports only gzip-encoding with the default data extension.
gzip
Datarobot-key: This header is required only with the managed AI Platform. It is used as a precaution to secure user data from other verified DataRobot users. The key can also be retrieved with the following request to DataRobot API: GET <URL>/api/v2/modelDeployments/<deploymentId>
To trigger prediction explanations, your request must send maxExplanations=N where N is greater than 0.
Key
Type
Description
Example(s)
maxExplanations
int OR string
(Optional) Limits the number of explanations returned by server. Previously called maxCodes (deprecated). For SHAP explanations only a special constant all is also accepted.
?maxExplanations=5
?maxExplanations=all
thresholdLow
float
(Optional) The lower threshold for requiring a Prediction Explanation. Predictions must be below this value (or above the thresholdHigh value) for Prediction Explanations to compute.
?thresholdLow=0.678
thresholdHigh
float
(Optional) The upper threshold for requiring a Prediction Explanation. Predictions must be above this value (or below the thresholdLow value) for Prediction Explanations to compute.
?thresholdHigh=0.345
excludeAdjustedPredictions
bool
(Optional) Includes or excludes exposure-adjusted predictions in prediction responses if exposure was used during model building. The default value is true (exclude exposure-adjusted predictions).
?excludeAdjustedPredictions=true
explanationNumTopClasses
int
(Optional) This argument is only for multiclass model explanations and it is mutually exclusive with explanationClassNames.
The number of top predicted classes to explain for each row. The default value is 1.
?explanationNumTopClasses=5
explanationClassNames
list of string types
(Optional) This argument is only for multiclass model explanations and it is mutually exclusive with explanationNumTopClasses.
A list of class names to explain for each row. Class names must be passed as UTF-8 bytes and must be percent-encoded (see the HTTP standard for this requirement). By default, explanationNumTopClasses=1 is assumed.
PassengerId,Pclass,Name,Sex,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked 892,3,"Kelly, Mr. James",male,34.5,0,0,330911,7.8292,,Q 893,3,"Wilkes, Mrs. James (Ellen Needs)",female,47,1,0,363272,7,,S 894,2,"Myles, Mr. Thomas Francis",male,62,0,0,240276,9.6875,,Q
The "qualitativeStrength" indicates the effect of the feature's value on predictions, based on XEMP calculations. The following table provides an example for a model with two features. See the XEMP calculation reference for full calculation details.
Note
This response is an XEMP-only feature.
Indicator...
Description
+++
Absolute score is > 0.75 and feature has positive impact.
---
Absolute score is > 0.75 and feature has negative impact.
++
Absolute score is between (0.25, 0.75) and feature has positive impact.
--
Absolute score is between (0.25, 0.75) and feature has negative impact.
+
Absolute score is between (0.001, 0.25) and feature has positive impact.
-
Absolute score is between (0.001, 0.25) and feature has negative impact.
<+
Absolute score is between (0, 0.001) and feature has positive impact.
<-
Absolute score is between (0, 0.001) and feature has negative impact.