Explaining Predictions with SageMaker Clarify
This lesson explains how SageMaker Clarify provides model-agnostic explanations that show why a model made a prediction, for regulated decisions, debugging and trust.
Learning outcomes
After completing this lesson, you will be able to:
- Interpret SHAP values for a prediction.
- Run a Clarify explainability job with a baseline.
- Monitor feature attribution drift in production.
SHAP values
Clarify uses SHAP (SHapley Additive exPlanations), based on Shapley values from game theory. For one prediction, each feature receives a value showing how much it pushed the prediction up or down from a baseline (a reference input, such as the average record). The values add up to the difference between the prediction and the baseline prediction, so explanations are consistent. Averaging absolute SHAP values over many predictions gives global feature importance.
The following diagram shows how SHAP contributions build up the default probability predicted for a declined loan applicant.

Add up the SHAP values
Running Clarify
A Clarify processing job takes the dataset, a model (deployed to a temporary shadow endpoint) and a configuration with the baseline and the number of samples, and writes a report with global importance, per-record SHAP values and partial dependence plots (how the prediction changes as one feature varies). Clarify also explains NLP models (importance of tokens or phrases) and computer vision models (image regions). Online explainability returns SHAP values with each real-time prediction from an endpoint.
Explainability in production
Explanations matter after deployment as well as before it. SageMaker Model Monitor can run Clarify on data captured from an endpoint to detect feature attribution drift: a change over time in which features drive the model's predictions. Such a change signals that the model's behaviour has shifted, often because the input data has changed, even when accuracy has not yet visibly dropped.
Explanations and their analysis can be documented in SageMaker Model Cards, which give auditors and stakeholders a record of how the model reaches its decisions. The following table summarises the explanation types.
| Explanation | Answers | Clarify feature |
|---|---|---|
| Local SHAP values | Why this prediction? | Per-record SHAP, online explainability |
| Global importance | Which features matter overall? | Mean absolute SHAP |
| Partial dependence | How does the prediction change with one feature? | PDP in the report |
| Attribution drift | Has feature importance changed in production? | Model Monitor with Clarify |
Explanations in production
Explaining a declined loan
A lender must give each declined applicant the main reasons. The model is XGBoost on an endpoint, and the baseline is the average approved applicant.
Prediction: P(default) = 0.42 (baseline 0.08)
Feature SHAP contribution
debt_to_income = 0.61 +0.19
missed_payments_12m = 3 +0.11
credit_history_years = 1 +0.06
income = 85,000 -0.02
Sum of contributions = +0.34 = 0.42 - 0.08The decline letter lists high debt-to-income ratio, recent missed payments and short credit history. Enabling online explainability on the endpoint returns these values with each prediction, so no separate batch job is needed for each applicant.
How is overall feature importance calculated from SHAP values?
Show answer
As the mean absolute SHAP value of each feature across predictions.
Exam Tips
Remember for the exam
- Why this prediction: Clarify SHAP values.
- Overall feature importance: mean absolute SHAP values.
- SHAP values are relative to a baseline input.
- Explanations with real-time predictions: Clarify online explainability.
- Feature importance changing in production: feature attribution drift monitor.