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.


Install NICE through Pypi

pip install NICEx

or github

pip install git git+ 


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,X_train,cat_feat,num_feat,y_train,optimization='sparsity')
# explain an instance


NICE on Adult


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 hashes)

Uploaded source

Built Distribution

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

Uploaded py3

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