Skip to main content

Disentangling Interactions and Dependencies (DIP) Decomposition.

Project description

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:

pip install dipd

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

git clone https://github.com/gcskoenig/dipd
cd dipd
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

explainer = DIP(df, target_variable, EBM)
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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dipd-0.0.1.tar.gz (75.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dipd-0.0.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file dipd-0.0.1.tar.gz.

File metadata

  • Download URL: dipd-0.0.1.tar.gz
  • Upload date:
  • Size: 75.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for dipd-0.0.1.tar.gz
Algorithm Hash digest
SHA256 04c6f6e06201f572d2f02422d8da1abccb0e8c0e74fd07d9d5166516dab2a75a
MD5 fe64048382faed2c2a5e672930bfc145
BLAKE2b-256 25e5479cf42707944e2225769616a5e808729eab91a0ce370cf703861f44e0d0

See more details on using hashes here.

File details

Details for the file dipd-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: dipd-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for dipd-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a8042918932bd86e7c89fbaa221dcc772f59f5576ce04b27a77d539d79896248
MD5 231e9c77f73f58f9b8730c0aa11d12ec
BLAKE2b-256 6841eb44bb56e9d15c2b7ef819b91579444dc40872ac29cb5309de41c2955e38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page