Saliency maps and Grad-CAM — short for Gradient-weighted Class Activation Mapping — both needed to reach inside a convolutional network's own structure. What explains a prediction from a model with no gradients to inspect at all — a random forest, a rules engine, anything you can only query, never open up?
The curve is a "black box" — LIME — short for Local Interpretable Model-agnostic Explanations — never sees its formula, only its outputs. Drag the query point : LIME samples a few points near it, weights the close ones more than the far ones, and fits the simplest possible model — a straight line — through just that weighted neighborhood.
Around a query point , take samples nearby, weight each by a kernel that favors closeness, and fit a weighted linear regression:
- — the query point: the specific input whose prediction is being explained.
- — one of the sample points drawn near .
- — the weight given to sample , which shrinks the farther is from .
- — the kernel width, controlling how quickly the weight falls off with distance.
- — the local linear model's predicted output.
- — the two parameters of the local straight-line fit.
- A weighted least-squares fit
The slope and intercept minimize — an ordinary least-squares fit, just with each point's error scaled by how close it is to .
- Model-agnostic by construction
Nothing here needs the black box's internals: LIME only ever calls it as a function, exactly like a saliency map does, but a linear fit instead of a per-input gradient.
Drag anywhere and compare LIME's local slope to the curve's actual derivative at that point, — a fact LIME itself never gets to see, since it only ever queries the black box, never its formula. Watch how closely a local, linear approximation can still track a genuinely curved function, as long as it's never asked to explain anywhere but right around .
The black box computes (unknown to LIME). At , with kernel width , LIME samples , giving :
- Fit the weighted local line
The Gaussian kernel weight for each offset , :
- :
- :
- :
- :
- :
These are symmetric around , so the weighted mean of is exactly , and the weighted mean of comes out to (pulled above by the two farthest, largest- samples). Plugging every sample's pair into the weighted least-squares slope formula, , gives slope ; the intercept then follows from .
- Compare to the true derivative
, so — LIME's local slope matches the exact derivative, even though LIME never computed a derivative at all, only fit a line through five sampled points.
- But the line doesn't pass through (3, 9)
At the fitted line gives , not . LIME's local model tracks the slope faithfully — that's what makes it a good explanation of sensitivity — but it's a regression through a neighborhood, not an interpolation pinned to the exact point.
Drag x₀ until LIME's local slope reaches at least 10.
LIME's entire trick is scope: don't explain the whole model, just the tiny neighborhood around one prediction, where almost anything looks roughly linear. That's also its limitation — the same black box gets a different local explanation at every point you ask about, and none of them say anything reliable once you're far from where they were fit. The next two chapters take a different approach: a single, game-theoretically justified way to split credit among features, valid everywhere at once.