Explanation methods

Explanation methods

KernelSHAP, permutation Shapley, LIME, occlusion and Grad-CAM: what each computes and when to use it.

method on POST /v1/explanations picks the attribution algorithm. GET /v1/models/{model} lists the methods a model supports in explain_methods, the recommended one first.

MethodWhat it computesNeedsNotes
shapKernelSHAP. Weighted linear regression over feature coalitions, each coalition averaged over background rows. Attributions sum to output.value − base_value.Tabular, runnableUp to 12 features every coalition is enumerated, so the result is exact for the sampled background and reproducible. Above that a coalition budget (n_samples) is drawn.
shapleyPermutation Shapley sampling. Marginal contributions over n_permutations random feature orders.Tabular, runnableEach top_features row carries a stderr. The default auto for tables.
limeA local linear surrogate fitted to perturbed neighbours of the input (feature noise for tables, on/off regions for images).Any runnable modeloptions.local_r2 reports the surrogate's fit; kernel_width the locality.
occlusionHides each image region (blur for photos, gray for thumbnails) and measures the change in the target class's log-odds.Image, runnableThe default auto for images. Works for remote endpoints too.
gradcamClass-activation map from the last convolutional feature map of an uploaded network, read by central differences.Image, uploaded structureoptions.layer picks another spatial layer. Heatmap in [0, 1].
autoshapley for tables, occlusion for images.—Stored under the method actually used.
attributionsNo computation. You send the attributions, Kaimei stores and ranks them.Nothingmethod is recorded as provided. See bring your own attributions.

Wide inputs are handled by screening: above 96 features, Shapley sampling first finds the features that move the output (in groups when there are tens of thousands), samples over the strongest 48, and reports the rest as one residual so the attributions still sum to f(x) − E[f(z)]. LIME and KernelSHAP refuse inputs wider than 4,096 features.

Image explanations time one copy of the picture first and coarsen their region grid (and LIME's samples) so the whole explanation finishes within the API's 40-second budget; the response then also carries grid_requested or n_samples_requested and budget_seconds.