Skip to main content

No project description provided

Project description

shapleychains lib

Official code for the paper Shapley chains: Extending Shapley values to Classifier chains

Installation

Run the following to install

pip install shapleychains

Usage

from shapleychains import ChainContrib
from shapleychains import get_direct_positive, get_direct_unsigned, draw_features_contribs, get_indirect_unsigned, xor

from sklearn.multioutput import ClassifierChain
from sklearn.linear_model import LogisticRegression


df = xor()

var_x = ['X1', 'X2']

var_y = ['AND', 'OR', 'XOR']

train_xor = df.iloc[:16,:]
test_xor = df.iloc[16:,:]

chain_xor_LR = ClassifierChain(LogisticRegression())
chain_xor_LR.fit(train_xor[var_x], train_xor[var_y])

cc_LR = ChainContrib(df, var_x, var_y, chain_xor_LR.estimators_, explainer='Kernel')


dc = cc_LR.get_direct_contrib()
ic = cc_LR.get_indirect_contrib(dc)
di_pos = get_direct_positive(dc, len(var_x))
di_posneg = get_direct_unsigned(dc, len(var_x))
ic_posneg = get_indirect_unsigned(ic)

raw, normalized = draw_features_contribs(var_x, var_y, dc, ic)

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

shapleychains-0.0.1.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

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

shapleychains-0.0.1-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: shapleychains-0.0.1.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for shapleychains-0.0.1.tar.gz
Algorithm Hash digest
SHA256 767db6fc4175baf98abb221a1be2fe78b3bba448b21f2fc4e563f73e5b40772a
MD5 f789bc754ffa1c9a7df56ced422a00f7
BLAKE2b-256 4140066dd3b5fdd4ca15479017a4d53893165573ab11b999868f4a117f11aea2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: shapleychains-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for shapleychains-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 132b1552affa05a16d67cd7e1c698476b63646ffb57ff4393b2fe9ee4440881f
MD5 664367ff10588ac8d39f87469e697b15
BLAKE2b-256 71a5fa06e064048d85fe60eae3bc45319359f088b0128b4359f0a0612edb6025

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