Skip to main content

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

Metadata

Release files for NICEx 0.2.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 NICEx 0.2.3
File Size Uploaded Provenance
NICEx-0.2.3.tar.gz 8.9 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 19.5 kB

Release files / NICEx-0.2.3.tar.gz

Download URL NICEx-0.2.3.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
78993b8009d1642d119378b8c4b78e610d72f203c4d5fb62a231de1baf192aa2
BLAKE2b-256 checksum
How to use checksums
fb77748f20541c9295315702381f3949cbaa393c81e3fa653737f619160fa255
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / NICEx-0.2.3-py3-none-any.whl

Download URL NICEx-0.2.3-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd70d4b93b9702b7e03c5179508f56622182153fba68bf0d98120de64dd458a3
BLAKE2b-256 checksum
How to use checksums
70dd955bebd29011e1bbec9bd29fd5faf28135ff443d6634106d45063e829913
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for NICEx 0.2.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