Quick Reference · ML explainability & interpretability

shapash cheat sheet

Shapash is an overlay on top of SHAP / LIME by MAIF. One SmartExplainer binds your model, data and encoders together, then a single vocabulary of xpl.plot.* calls turns raw contributions into labelled, human-readable plots — plus a web app, an audit-ready HTML report, and a light deployment object. Learn the pipeline once and the methods stop being a list to memorise.

build (model & data) explain (compile) plot / visualise report & deploy explainability quality most common

Distilled & cross-checked across: shapash.readthedocs.io · github.com/MAIF/shapash · maif.github.io/shapash · pypi.org/project/shapash · towardsdatascience.com · verified 2026-08-28 against Shapash 2.9.0 (Python 3.11–3.14; overlays current SHAP/LIME + Plotly) · SmartExplainer / SmartPredictor API

The pipeline & the methods that move you along it
YOU BRING THESE THE SHAPASH CORE OUTPUTS trained model xgboost · lightgbm · sklearn · catboost X test · y · encoder + features_dict for labels SmartExplainer binds model + data + shap/lime .compile(x=Xtest, …) → computes contributions init plots xpl.plot.features_importance() · contribution_plot() … web app xpl.run_app() — navigate global ⇄ local report xpl.generate_report() — standalone audit HTML deploy xpl.to_smartpredictor() — light, API / batch trust the explanation? 3 quality metrics — how much can you rely on these contributions Stability similar rows → similar reasons Consistency shap vs lime agree? Compacity few features enough? evaluate
01Install & Importonce per env
02Bring a Modelwhat Shapash wraps
03Declare Explainerstep 1 · bind it
04Compilestep 2 · the workhorse
05Global Plotsstep 3 · the big picture
06Local Plotsexplain one prediction
07Summarise & Exporttune the local story
08Explainability Qualitycan you trust it?
09Web Appnavigate interactively
10Audit Reportstep 4 · standalone HTML
11Deploy · SmartPredictorstep 5 · production
12Save & Reloadpersist the explainer
Select a Rowanywhere you pick an instance

The five plots you'll actually use

Every plot is one xpl.plot.* call on a compiled explainer. Sketches below show the shape of each output — the real ones are interactive Plotly figures with your feature labels.

features_importance()

Global ranking — the sum of absolute contributions per feature. Your first look at what the model leans on.

SexPclass AgeFareEmbark

contribution_plot('Age')

How one feature's value maps to its contribution. Auto-picks violin (categorical) or scatter (continuous).

feature value → contrib →

local_plot(index=42)

One prediction, decomposed. Green pushes the output up, red pulls it down — the ± drivers for that single row.

0 Sex=F Pclass=3

compare_plot(row_num=[0,1,2])

Several individuals overlaid on the same feature axis — see at a glance why their predictions diverge.

AgeFare SexPclEmb #0

stability_plot()

Quality check: for similar instances, are contributions similar? Points near the axis = stable, trustworthy explanations.

variability across neighbours → amplitude →

compacity_plot()

Quality check: how many features are enough to reproduce ~90% of the output? A curve that plateaus early = a simple story.

90% # features → % explained →

Worth memorising

overlay, not methodShapash wraps shap / lime — it doesn't compute values itself
global vs localfeatures_importance = whole model · local_plot = one row
only 2 required argsmodel at init · x at compile — rest is optional polish
features_dictthe single biggest readability win — map codes to labels
filter ➜ to_pandasfilter() sets the summary; to_pandas() exports that same view
3 quality metricsStability · Consistency · Compacity — trust before you ship
Explainer ≠ PredictorSmartExplainer = analysis · SmartPredictor = light deploy
report needs extraspip install shapash[report] before generate_report()