Inferensys

Glossary

SHAP Values

SHAP (SHapley Additive exPlanations) values are a game-theoretic approach to explain machine learning model outputs by computing the marginal contribution of each feature to a prediction.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
MODEL INTERPRETABILITY

What is SHAP Values?

SHAP (SHapley Additive exPlanations) values are a game-theoretic approach to explain the output of any machine learning model by computing the marginal contribution of each feature to a specific prediction.

SHAP values quantify the impact of each molecular feature on a model's prediction by calculating its average marginal contribution across all possible feature subsets. Rooted in cooperative game theory, this method assigns an importance score to each descriptor—such as LogP, molecular weight, or a specific ECFP bit—by comparing the model's output with and without that feature, ensuring a fair and consistent distribution of credit.

In molecular property prediction, SHAP analysis reveals why a model flagged a compound for hERG cardiotoxicity or predicted high oral bioavailability, moving beyond a black-box score to an atomistic or substructural rationale. This local and global interpretability is critical for guiding medicinal chemistry decisions, debugging models by identifying spurious correlations, and satisfying the rigorous applicability domain and algorithmic explainability requirements of preclinical development.

GAME-THEORETIC EXPLAINABILITY

Key Properties of SHAP Values

SHAP (SHapley Additive exPlanations) values provide a unified framework for interpreting molecular property predictions by assigning each feature an importance value for a particular prediction, grounded in cooperative game theory.

01

Local Accuracy

The sum of all feature attributions equals the difference between the model's prediction for a specific molecule and the average prediction across the dataset. This property, also known as efficiency, ensures the explanation is a faithful decomposition of the output. For a toxicity prediction model, if the base value is 0.3 and the prediction is 0.8, the SHAP values for all molecular fragments will sum to exactly 0.5.

02

Missingness

A feature that is already missing from the input—such as a structural fragment not present in the molecule—is guaranteed an attribution of zero. This prevents the explanation from arbitrarily assigning importance to absent substructures. In molecular fingerprinting, bits representing absent circular substructures will not influence the SHAP explanation for that compound.

03

Consistency

If a model is retrained so that a feature's marginal contribution increases or stays the same regardless of other features, the SHAP value for that feature will never decrease. This formal guarantee ensures that explanations track model behavior logically. If a retrained hERG cardiotoxicity model relies more heavily on a basic amine substructure, its SHAP value will reflect this increased dependence.

04

Additivity

SHAP values are linearly additive across models. For an ensemble method like a random forest predicting logP, the SHAP value for a functional group is the average of its SHAP values across all individual trees. This property extends to explaining multi-task models, where the importance of a molecular feature for a combined ADMET score can be decomposed into its contributions to individual endpoints.

05

Symmetry

If two features contribute identically to the model's output in every possible coalition of other features, they receive identical SHAP values. In molecular property prediction, two topologically equivalent atoms in a symmetric molecule—such as the two methyl groups in para-xylene—will be assigned equal importance for any prediction, preserving chemical symmetry in the explanation.

06

Kernel SHAP Estimation

Exact SHAP computation is exponential in the number of features, making it intractable for high-dimensional molecular representations. Kernel SHAP is a model-agnostic approximation that uses a weighted linear regression over sampled coalitions. For a molecule encoded with 2048-bit ECFP4 fingerprints, Kernel SHAP samples subsets of bits to estimate their contributions without evaluating all 2^2048 possible coalitions.

SHAP VALUES EXPLAINED

Frequently Asked Questions

Clear, technically precise answers to the most common questions about SHapley Additive exPlanations and their application in molecular property prediction and model interpretability.

SHAP (SHapley Additive exPlanations) values are a game-theoretic approach to explain the output of any machine learning model by computing the marginal contribution of each feature to a specific prediction. The method is rooted in Shapley values from cooperative game theory, where the 'game' is the prediction task and the 'players' are the input features. SHAP assigns each feature an importance value by considering all possible subsets of features and calculating how the prediction changes when a feature is included versus excluded. The result is an additive feature attribution where the sum of all SHAP values equals the difference between the model's actual prediction and the average prediction. For molecular property prediction, this means you can decompose a predicted LogP or hERG inhibition value into contributions from individual atoms, functional groups, or molecular descriptors, providing a transparent audit trail for regulatory-critical decisions.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.