Practical overview
When it fits
Use SHAP when you have a model and want local explanations for its predictions or aggregate views of feature effects across a dataset.
Who it is for
- Machine-learning practitioners who need to interpret model predictions.
- Analysts comparing feature effects across examples or datasets.
Documented uses
- Explain which features push an individual prediction higher or lower.
- Visualize feature contributions across multiple model predictions.
- Inspect how a feature relates to model output and possible interactions.
- Summarize feature importance using attribution values.
Requirements & limits
The library is open source under the MIT license and can be installed from PyPI or conda-forge. GPU-accelerated Tree SHAP requires installation from source and the CUDA toolkit.
- The README identifies fast C++ implementations for XGBoost, LightGBM, CatBoost, scikit-learn and pyspark tree models.
- The project describes specific support for natural-language models through Hugging Face Transformers pipelines.
- GPU acceleration is documented for Tree SHAP and has a CUDA toolkit prerequisite.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install SHAP from PyPI or conda-forge
Set up the SHAP Python library using one of its documented package channels.
Before you start
- A Python environment with the selected package manager available.
Steps
Choose either PyPI or conda-forge as the installation channel.
For PyPI, run the command below; alternatively, for conda-forge, run
conda install -c conda-forge shap.pip install shap
Expected outcome
SHAP is installed through the selected package channel.
Guide limitations
- The source does not give additional environment setup or troubleshooting steps.
- GPU-accelerated Tree SHAP has separate requirements; see the repository README.
Explain a tree-ensemble model prediction with SHAP
Generate SHAP values for an XGBoost model and visualize one prediction's feature contributions.
Before you start
- SHAP installed.
- XGBoost available in the Python environment.
- A trained or trainable XGBoost regression setup and input data; the README example uses SHAP's California dataset.
Steps
Import
xgboostandshap.Load the California dataset with
X, y = shap.datasets.california()and fitmodel = xgboost.XGBRegressor().fit(X, y).Create an explainer and calculate values with
explainer = shap.Explainer(model)andshap_values = explainer(X).Visualize the first prediction using
shap.plots.waterfall(shap_values[0]).
Expected outcome
A waterfall visualization displays feature contributions for the first prediction, showing how they move the model output from its base value.
Guide limitations
- The example demonstrates XGBoost; fast C++ tree implementations are also identified for LightGBM, CatBoost, scikit-learn, and pyspark models.
- The base value in the example is the average model output over the training dataset passed to the explainer.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 12 October 2026
- Original website title
- shap/shap · Official homepage title · retained in its source language

