Skip to main content

DIP Decomposition Package (dipd)

The DIP Decomposition is a loss-based global feature attribution technique, that explains how much each feature contributes to the predictive performance. In contrast to standard feature attribution techniques it separates the standalone contributions of the individual features and cooperative contributions stemming from interactions and dependencies between features.

The DIP decomposition was introduced in this paper, titled "Disentangling Interactions and Dependencies in Feature Attribution".

Installation

dipd requires Python 3.11 or newer and can be installed from PyPI:

uv pip install dipd

For a development installation, clone the repository and install in editable mode:

git clone https://github.com/gcskoenig/dipd
cd dipd
uv pip install -e .

Usage

As follows we illustrate the package on a reduced version of the California housing dataset with just three features: longitude, latitude, and ocean proximity. Specifically, we compute and decompose the Leave-One-Covariate-Out (LOCO) scores based on explainable boosting machines (EBM) and decompose these scores into the feature's standalone contribution, and the contributions stemming from interactions and dependencies with the remaining features.

## load data and preprocess data
import pandas as pd
import category_encoders as ce

varnames = ['longitude', 'latitude', 'ocean_proximity', 'median_house_value']
target_variable = 'median_house_value'
df = pd.read_csv('https://raw.githubusercontent.com/ageron/handson-ml2/master/datasets/housing/housing.csv').dropna()[varnames]
encoder = ce.OrdinalEncoder()
df = encoder.fit_transform(df)

## perform leave-one-covariate-out DIP decomposition
from dipd import DIP
from dipd.learners import EBM

# exemplary hyperparameters for the EBM learner (passed to ExplainableBoostingRegressor)
learner_kwargs = {'max_rounds': 500, 'learning_rate': 0.05}

explainer = DIP(df, target_variable, EBM, learner_kwargs=learner_kwargs)
explanation = explainer.get_all_loo()
print(explanation.scores)

## plot the results
import matplotlib.pyplot as plt
from dipd.plots import forceplot

ax = forceplot(explanation.scores.T, 'DIP Decomposition of LOCO scores',
               figsize=(3, 3), explain_surplus=True)
ax.get_legend().remove()
plt.show()

The code produces the following plot.

Forceplot DIP Decomposition

The plot can be interpreted as follows: Each bar explains one LOCO score as the sum of standalone contribution (gray) and the contributions of interactions (green) and dependencies (purple). Each bar is visualized as a forceplot, meaning that the direction of each bar indicates the sign, where downward facing bars are negative contributions and upward facing bars positive contributions. The bars sum up to the black horizontal lines, which are the LOCO scores of the features.

Metadata

Release files for dipd 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dipd 0.0.3
File Size Uploaded Provenance
dipd-0.0.3.tar.gz 76.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dipd 0.0.3
File Interpreter ABI Platform
dipd-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 92.7 kB

Release files / dipd-0.0.3.tar.gz

Download URL dipd-0.0.3.tar.gz
Size 76.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1d8077708f39517439873a919f3c98d1a8fe7c6df6b76080b98bad8849f12c61
BLAKE2b-256 checksum
How to use checksums
d932aadf1f1dca5a2005d7ef5f70fc20c966ff4a79214fbe9226f0c60364e78d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / dipd-0.0.3-py3-none-any.whl

Download URL dipd-0.0.3-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0cff931ae47bf29c701a47728c5e82ac7e751378de85963269bc9a0902118b6f
BLAKE2b-256 checksum
How to use checksums
6263f42b07fc963df762e4055f676de9e0cfc444ef66c2dd3769b593914ff761
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for dipd 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page