Skip to main content

Nearest Instance Counterfactual explanations

Project description

Nearest Instance Counterfactual Explanations (NICE)

NICE is an algorithm to generate Counterfactual Explanations for heterogeneous tabular data. Our approach exploits information from a nearest instance to speed up the search process and guarantee that an explanation will be found.

Installation

Install NICE through Pypi

pip install NICEx

or github

pip install git git+https://github.com/ADMantwerp/nice.git 

Usage

NICE requires acces to the prediction score and trainingdata to generate counterfactual explanations.

from nice import NICE

# Initialize NICE by specifing the optimization strategy
NICE_explainer = NICE(optimization='sparsity')
# Fit our NICE explainer on the training data and classifier
NICE_explainer.fit(predict_fn,X_train,cat_feat,num_feat,y_train,optimization='sparsity')
# explain an instance
NICE_explainer.explain(x)

Examples

NICE on Adult

References

NICE: An Algorithm for Nearest Instance Counterfactual Explanations

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

NICEx-0.2.3.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

NICEx-0.2.3-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file NICEx-0.2.3.tar.gz.

File metadata

  • Download URL: NICEx-0.2.3.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.4

File hashes

Hashes for NICEx-0.2.3.tar.gz
Algorithm Hash digest
SHA256 78993b8009d1642d119378b8c4b78e610d72f203c4d5fb62a231de1baf192aa2
MD5 7dfb2002c569db1eed9fbeeb58e8b8a9
BLAKE2b-256 fb77748f20541c9295315702381f3949cbaa393c81e3fa653737f619160fa255

See more details on using hashes here.

File details

Details for the file NICEx-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: NICEx-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.4

File hashes

Hashes for NICEx-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cd70d4b93b9702b7e03c5179508f56622182153fba68bf0d98120de64dd458a3
MD5 81d96bda6dc490781005933b746083e1
BLAKE2b-256 70dd955bebd29011e1bbec9bd29fd5faf28135ff443d6634106d45063e829913

See more details on using hashes here.

Supported by

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