FOCUS is a python package for generating counterfactual explanations for a tree-based model
Project description
Deployment & Documentation & Stats & 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.
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file focus-cfe-0.0.dev3.tar.gz
.
File metadata
- Download URL: focus-cfe-0.0.dev3.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35e226a2d635d7e20dfbdd057481728cc50d6ee02456e4312cacb0b694296713 |
|
MD5 | cee018e399aec6095238f107ea906dac |
|
BLAKE2b-256 | 888f70ffb687432922d2fd3574d762655c50dbab51c6cf60aab59c1a21d7db97 |