Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

FOCUS: Flexible Optimizable Counterfactual Explanations for Tree Ensembles

Deployment & Documentation & Stats & License

PyPI version Documentation status Downloads https://codecov.io/gh/kyosek/focus/branch/master/graph/badge.svg?token=G5I7TJR0JQ Circle CI 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.

Limitations:

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

  • While categorical features may be included in the feature set, it is important to note that the interpretation of changes in categorical features, such as transitioning from age 40 to 20, may not provide meaningful insights.

  • The input features should be scaled to the range of 0 and 1 before applying FOCUS. Therefore, it is necessary to transform the features prior to using FOCUS. However, this scaling process may introduce some additional complexity when interpreting the features after applying FOCUS.


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

Metadata

Release files for focus-cfe 0.0.dev3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for focus-cfe 0.0.dev3
File Size Uploaded
focus-cfe-0.0.dev3.tar.gz 13.2 kB Details

Release files / focus-cfe-0.0.dev3.tar.gz

Download URL focus-cfe-0.0.dev3.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
35e226a2d635d7e20dfbdd057481728cc50d6ee02456e4312cacb0b694296713
BLAKE2b-256 checksum
How to use checksums
888f70ffb687432922d2fd3574d762655c50dbab51c6cf60aab59c1a21d7db97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.3
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