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.
| Method | What it computes | Needs | Notes |
|---|---|---|---|
shap | KernelSHAP. Weighted linear regression over feature coalitions, each coalition averaged over background rows. Attributions sum to output.value − base_value. | Tabular, runnable | Up 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. |
shapley | Permutation Shapley sampling. Marginal contributions over n_permutations random feature orders. | Tabular, runnable | Each top_features row carries a stderr. The default auto for tables. |
lime | A local linear surrogate fitted to perturbed neighbours of the input (feature noise for tables, on/off regions for images). | Any runnable model | options.local_r2 reports the surrogate's fit; kernel_width the locality. |
occlusion | Hides each image region (blur for photos, gray for thumbnails) and measures the change in the target class's log-odds. | Image, runnable | The default auto for images. Works for remote endpoints too. |
gradcam | Class-activation map from the last convolutional feature map of an uploaded network, read by central differences. | Image, uploaded structure | options.layer picks another spatial layer. Heatmap in [0, 1]. |
auto | shapley for tables, occlusion for images. | — | Stored under the method actually used. |
| attributions | No computation. You send the attributions, Kaimei stores and ranks them. | Nothing | method 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.