Skip to main content

FOCUS is a python package for generating counterfactual explanations for a tree-based model

Project description

Deployment & Documentation & Stats & License

PyPI version Documentation status GitHub stars GitHub forks Downloads Coverage Status Maintainability pre-commit License

This library is an implementation of FOCUS: Flexible Optimizable Counterfactual Explanations for Tree Ensembles.

FOCUS generates optimal distance counterfactual explanations to the original data for all the instances in tree‐based machine learning models.

FOCUS counterfactual explanation generation with 3 Lines of Code:

from focus import Focus
# Initialize Focus instance with default values
focus = Focus()
# Generate counterfactual explanations for given tree model and features
pertubed = focus.generate(tree_model, X)

Examples:

  • More comprehensive example can be found in the examples folder.

  • Another example in a kaggle notebook can be found here.

  • Below demonstrates the comparison of before and after FOCUS was applied to feature set from the above example.

Before and After FOCUS was applied to the features from above example.

Note:

Currently FOCUS can be applied to scikit-learn DecisionTreeClassifier, RandomForestClassifier and AdaBoostClassifier.

Installation

It is recommended to use pip or conda for installation. Please make sure the latest version is installed:

pip install focus-cfe            # normal install
pip install --upgrade focus-cfe  # or update if needed
conda install -c conda-forge focus-cfe

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

focus-cfe-0.0.dev2.tar.gz (12.7 kB view details)

Uploaded Source

File details

Details for the file focus-cfe-0.0.dev2.tar.gz.

File metadata

  • Download URL: focus-cfe-0.0.dev2.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.3

File hashes

Hashes for focus-cfe-0.0.dev2.tar.gz
Algorithm Hash digest
SHA256 c82987dabc2e7746d4d654aaa1b787132cd8ce20f4c79fd0ec3ff2fe6927a1fc
MD5 8a64eb9a7647ed5fcb12070b044bf24c
BLAKE2b-256 8f9fab53518733c4546f16beabc643dfb07848f0c4bdafcee9ac07659fcc47f3

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