Skip to content

Audit a model's explanations

Which parts of a model's explanation can you check, and which depend on choices the bars never show?

Capstone 20~50 minadvanced Customers (simulated)

The story

A retention team wants every account manager to see why the churn model flags a customer, with one bar per column: age, income, months as a customer, plan, region and recent visits. Before the bars reach anyone, the team's reviewer asks four questions. Do the numbers add up to the prediction they explain? Do different explainers tell the same story, and what is that agreement worth? Would the bars change if someone picked a different reference customer, the baseline? And would they change if the model had learned nothing at all?

You'll answer in Predict with a logistic regression, a model simple enough that each check has a known right answer, and finish the last question in a notebook, because CodeSplash doesn't scramble a saved model's weights. The data are simulated, so nothing here describes real people.

Data: Customers (simulated) · Simulated. CodeSplash parity fixture g1_customers (simulated, seed 20261103).

Stage 1 · model · ~12 min

Train the model to explain

An explanation describes one fitted model, so start with the model. Predict churned with logistic regression, whose every prediction is a weighted sum you can read. That makes it a good test bed: several of the checks below have a known right answer for a linear model, so you can tell a working check from a broken one.

Which columns does the model use, and what does it predict for each customer?

  1. Open Predict in the sidebar.
  2. Press New experiment, choose customers (sample) and press Create.
  3. Set Target to churned.
  4. Press Continue on Setup, keep the suggested validation plan, and press Continue again.
  5. Select Linear / logistic regression.
  6. Press Train.

Stage 2 · model · ~14 min

Three Shapley explainers, one model

Ask for the same idea three ways: SHAP (linear), exact for this model on the log-odds scale; KernelSHAP, an estimate from predictions on feature subsets; and Exact Shapley, which enumerates every coalition. Add Check the explanations, which removes the top-ranked features first and asks whether predictions change faster than when random features go. Then read what each check can and can't tell you.

Do the values add up, does KernelSHAP match the exact values, and what is agreement worth here?

  1. Open the logistic regression run on the leaderboard.
  2. Open the Explanations tab.
  3. Tick SHAP (linear), KernelSHAP, Exact Shapley and Check the explanations.
  4. Press Explain. Exact Shapley and the check take a little longer than the rest.
  5. Read the Exact Shapley note under the charts. Each row's values add up to its predicted probability minus the average one. What does that check?Exact Shapley values add up by construction, so passing checks the computation, not the explanation.
  6. Read Check these explanations. Does KernelSHAP match exact Shapley, and is the ranking faithful to what moves the model?
  7. Read the agreement table. For a linear model these explainers are expected to rank the features nearly alike. How much does their agreement tell you?When explainers must agree by construction, agreement checks the arithmetic. It is a sanity check, not evidence of faithfulness.

Stage 3 · model · ~8 min

Move the baseline

Every attribution explains the change from a reference point, the baseline. Integrated Gradients lets you choose it: the training rows' mean, or every design column at zero. Run it with each and compare. Remember what the design columns are here: the numeric ones are standardized, so zero is already their training mean, while plan and region are one-hot columns, so an all-zero row has no plan and no region, as if both were missing.

What customer does each baseline stand for, and which bars move when it changes?

  1. Tick Integrated Gradients.
  2. Open Explanation settings, check that Baseline row is the training rows' mean, and press Explain. Note the baseline's score in the Integrated Gradients note.
  3. Now set Baseline row to All zeros and press Explain again.
  4. Compare with your notes. Did the baseline's score move? Which bars changed most, and what customer is an all-zero row?The baseline is part of the explanation. Change it and the same prediction gets different bars, so the report has to name it.

Stage 4 · notebooks · ~15 min

The randomization check, in a notebook

CodeSplash doesn't scramble a saved model's weights, so finish the audit in a notebook: a small network with written-out weights, Integrated Gradients with its completeness gap, and the same network with its weights redrawn. An explanation that barely changes when the weights are scrambled isn't explaining the model.

Do the attributions change when the weights are scrambled, and is one draw enough to say so?

Notebook exercise: Integrated Gradients and a randomization check. Compute Integrated Gradients for a small network, check completeness, and run the sanity check that an explanation must change when the weights are scrambled. 3 checks in Python or R.

Hints
  • Write the baseline next to every attribution chart. The bars explain the change from it, not the prediction itself.
  • Agreement between explainers that must agree by construction checks the arithmetic, not the explanation.
  • The bars describe how this model responds near these customers. They don't say what would make a customer stay.

appendix

Explanation audit appendix

Write the audit appendix the reviewer asked for: the model and rows you explained, each check and what it showed, the baseline you recommend reporting and why, the randomization check, and what the bars don't claim.

  1. Model and rows
  2. Additivity and agreement
  3. Faithfulness
  4. Baseline sensitivity
  5. Randomization check
  6. What the bars don't say
Rubric
CriterionPoints
Shows the exact Shapley values add up to each prediction minus the average, and says this checks the computation only.2
Reports how KernelSHAP compares with exact Shapley and why agreement among these explainers is weak evidence for a linear model.2
Reports the faithfulness check and what a failure would have meant.2
Compares the mean and all-zeros baselines, says which bars moved and why, and names the baseline to report.2
Reports the notebook's randomization check and notes that one draw is weak evidence.1
States that the bars describe the model near these customers, not causes or advice.1

Model answer

Show the model answer

Model and rows. A logistic regression predicts churned from age, annual income, months as a customer, plan, region and visits. Its preprocessing standardizes the numeric columns and one-hot encodes plan and region, learned inside each fold. Name the rows the Explanations tab explained and the scale of each explainer: SHAP (linear) works on log-odds, KernelSHAP and Exact Shapley on the predicted probability.

Additivity and agreement. Each row's exact Shapley values add up to its predicted probability minus the average prediction over the background rows, to rounding. That holds by construction, so it checks the code. KernelSHAP is an estimate of the same values; its check reports the largest gap from the exact ones, and a large gap calls for more background rows before reading the values. For a linear model the three are expected to rank the features nearly alike (the probability scale bends the log-odds contributions a little), so the agreement table is a sanity check rather than evidence that the bars are faithful.

Faithfulness. The deletion check removes the top-ranked features first and compares with random orders. Report its status as shown. A pass says the ranking follows what moves this model's predictions; it says nothing about whether the model is right.

Baseline sensitivity. Against the training rows' mean, Integrated Gradients splits each row's change from the average customer. Against all zeros, the numeric columns keep the same reference, because after standardizing zero is their training mean, but plan and region now start from the row the model sees when both are missing, which describes no real customer. The baseline's score moves and the bars change with it, plan and region's on their own. Report the mean baseline, and say why.

Randomization check. In the notebook, the network with redrawn weights orders its attributions differently from the real network, so Integrated Gradients passes this check there. One draw and one rank correlation are weak evidence; repeat with more seeds before leaning on it.

What the bars don't say. They describe how this model responds near these customers, relative to a stated baseline. They don't say what would keep a customer, and they don't make the model fair or right.