API reference#

The public API of Shapash. Each entry links to its full documentation.

Tabular data#

explainer.smart_explainer.SmartExplainer(model)

The main class of the Shapash library, to make machine learning model results understandable.

explainer.smart_plotter.SmartPlotter(explainer)

SmartPlotter is a Bridge pattern decoupling plotting functions from SmartExplainer.

explainer.consistency.Consistency([...])

Compare the contributions computed by several explainability methods.

explainer.smart_predictor.SmartPredictor(...)

The SmartPredictor class is an object lighter than SmartExplainer Object with additionnal consistency checks.

utils.load_smartpredictor.load_smartpredictor(path)

load_smartpredictor allows Shapash users to load SmartPredictor Object already saved into a pickle.

data.data_loader.data_loading(dataset)

Load one of the sample datasets supported by Shapash.

Report and standalone plots#

report.ReportTemplate(value)

Report templates list.

report.export_report_yml(template_id[, ...])

Export a report template YAML file to the given output path.

report.blocks.ReportBlockMixin([explainer, ...])

Base mixin providing built-in and user-extensible smart report blocks.

report.blocks.block(method)

Wrap block output in a standard report section container.

plots.plot_univariate.plot_distribution(...)

Plot the univariate distribution of a continuous or categorical feature in the dataset.

plots.plot_correlations.plot_correlations(df)

Plot a correlation matrix heatmap.

plots.plot_evaluation_metrics.plot_confusion_matrix(...)

Creates an interactive confusion matrix using Plotly.

plots.plot_feature_importance.plot_feature_importance(...)

Generate feature importance plots using different modes such as global, global-local, or cumulative contributions.

Backends#

backend.BaseBackend(model[, preprocessing])

BaseBackend is the base class for all tabular backends.

backend.ShapBackend(model[, preprocessing, ...])

The Shap Backend.

backend.LimeBackend(model[, preprocessing, data])

The Lime Backend.

Text data (NLP)#

explainer.nlp_explainer.NlpExplainer(model)

Minimal explainer for text classification — token-level contributions.

explainer.nlp_explanation.NlpExplanation(...)

Immutable result of explain().

explainer.nlp_plotter.NlpPlotter(explanation)

Plots over one NlpExplanation.

webapp.nlp_app.NlpWebApp(explanation[, ...])

Minimal Dash webapp driven by an NlpExplainer.

model.HFClassifierModel(classifier, tokenizer)

Full-capability adapter over a raw AutoModelForSequenceClassification + tokenizer.

model.HFPipelineModel(pipeline[, label_names])

Prediction-only adapter over a HuggingFace text-classification pipeline.

backend.NlpShapBackend([masker, ...])

SHAP backend for text classification models (HuggingFace pipelines, etc.).

backend.NlpLimeBackend([mask_string, ...])

LIME backend for text classification models.

backend.NlpCaptumLigBackend([...])

Layer Integrated Gradients backend for text classification models.