Examples & Tutorials¶

A collection of examples and tutorials demonstrating how to use shapiq for computing and visualizing Shapley interactions.

Approximators¶

Examples demonstrating each approximator in shapiq on the same synthetic cooperative game. All examples use a lightweight callable game with 8 players so they execute in under a second.

SVARM

SVARM

KernelSHAP

KernelSHAP

OwenSamplingSV

OwenSamplingSV

UnbiasedKernelSHAP

UnbiasedKernelSHAP

StratifiedSamplingSV

StratifiedSamplingSV

PermutationSamplingSV

PermutationSamplingSV

kADDSHAP

kADDSHAP

ProxySPEX

ProxySPEX

KernelSHAPIQ

KernelSHAPIQ

RegressionFBII

RegressionFBII

RegressionFSII

RegressionFSII

PermutationSamplingSII

PermutationSamplingSII

SHAPIQ Approximator

SHAPIQ Approximator

PermutationSamplingSTII

PermutationSamplingSTII

SVARMIQ

SVARMIQ

InconsistentKernelSHAPIQ

InconsistentKernelSHAPIQ

ProxySHAP

ProxySHAP

SPEX

SPEX

RegressionMSR

RegressionMSR

ExactComputer

ExactComputer

Basics¶

Introductory examples covering core shapiq concepts: Shapley value computation, custom cooperative games, and parallel computation.

Parallel Computation with joblib

Parallel Computation with joblib

Defining Custom Games

Defining Custom Games

Computing Shapley Values

Computing Shapley Values

Game Theoretic Concepts¶

Examples exploring game-theoretic concepts beyond Shapley values, such as the Core and the Egalitarian Least Core.

The Core: A Different View on Explanation

The Core: A Different View on Explanation

Language Models¶

Examples demonstrating how to explain language model predictions using shapiq with token-based cooperative games.

Explaining Sentiment Analysis

Explaining Sentiment Analysis

Nearest Neighbor Models¶

Examples for data valuation using efficient explanations of nearest-neighbor models.

Data Valuation with Nearest Neighbor Explainers

Data Valuation with Nearest Neighbor Explainers

Tabular Models¶

Examples for explaining tabular machine-learning models with shapiq, including scikit-learn, XGBoost, and TabPFN models.

Conditional Data Imputation

Conditional Data Imputation

SHAP-IQ with scikit-learn

SHAP-IQ with scikit-learn

Explaining TabPFN

Explaining TabPFN

Tree Models¶

Examples demonstrating TreeSHAP-IQ for explaining tree-based models, including LightGBM and custom tree structures.

TreeSHAP-IQ for Custom Tree Models

TreeSHAP-IQ for Custom Tree Models

TreeSHAP-IQ for LightGBM

TreeSHAP-IQ for LightGBM

Vision Models¶

Examples demonstrating how to explain image classification models using shapiq with image patch-based cooperative games.

Explaining a Vision Transformer

Explaining a Vision Transformer

Visualization¶

Examples showcasing shapiq’s visualization capabilities: force plots, beeswarm plots, SI graph plots, UpSet plots, and more.

Computing Shapley Values.

Computing Shapley Values.

UpSet Plot

UpSet Plot

SI Graph Plot

SI Graph Plot

Visualization Catalog

Visualization Catalog

Working with InteractionValues

Working with InteractionValues

Beeswarm Plot

Beeswarm Plot

Scatter Plot

Scatter Plot