FOCUS: Flexible Optimizable Counterfactual Explanations for Tree Ensembles
==========================================================================
**Deployment & Documentation & Stats & License**
.. image:: https://img.shields.io/pypi/v/focus-cfe.svg?color=brightgreen
:target: https://pypi.org/project/focus-cfe/
:alt: PyPI version
.. image:: https://readthedocs.org/projects/focus-cfe/badge/?version=latest
:target: https://focus-cfe.readthedocs.io/en/latest/?badge=latest
:alt: Documentation status
.. image:: https://pepy.tech/badge/focus-cfe
:target: https://pepy.tech/project/focus-cfe
:alt: Downloads
.. image:: https://codecov.io/gh/kyosek/focus/branch/master/graph/badge.svg?token=G5I7TJR0JQ
:target: https://codecov.io/gh/kyosek/focus
.. image:: https://dl.circleci.com/status-badge/img/gh/kyosek/focus/tree/master.svg?style=svg
:target: https://dl.circleci.com/status-badge/redirect/gh/kyosek/focus/tree/master
:alt: Circle CI
.. image:: https://api.codeclimate.com/v1/badges/93840d29606abb212051/maintainability
:target: https://codeclimate.com/github/kyosek/focus-cfe/maintainability
:alt: Maintainability
.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit
:target: https://github.com/kyosek/focus-cfe
:alt: pre-commit
.. image:: https://img.shields.io/github/license/kyosek/focus.svg
:target: https://github.com/kyosek/focus/blob/master/LICENSE
:alt: License
-----
This library is an implementation of `FOCUS: Flexible Optimizable Counterfactual Explanations for Tree Ensembles <https://arxiv.org/abs/1911.12199>`_.
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**\ :
.. code-block:: python
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 <https://github.com/kyosek/focus/blob/master/examples/focus_example.py>`_.
- Another example in a kaggle notebook can be found `here <https://www.kaggle.com/code/kyosukemorita/focus-cfe-example>`_.
- Below demonstrates the comparison of before and after FOCUS was applied to feature set from the above example.
.. image:: docs/plot.png
:width: 200px
:height: 100px
:scale: 50 %
:alt: 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:
.. code-block:: bash
pip install focus-cfe # normal install
pip install --upgrade focus-cfe # or update if needed
.. code-block:: bash
conda install -c conda-forge focus-cfe
Raw data
{
"_id": null,
"home_page": "",
"name": "focus-cfe",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python,counterfactual explanation,binary classification,machine learning",
"author": "Kyosuke Morita",
"author_email": "kq441morita@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/88/8f/70ffb687432922d2fd3574d762655c50dbab51c6cf60aab59c1a21d7db97/focus-cfe-0.0.dev3.tar.gz",
"platform": null,
"description": "FOCUS: Flexible Optimizable Counterfactual Explanations for Tree Ensembles\n==========================================================================\n\n**Deployment & Documentation & Stats & License**\n\n.. image:: https://img.shields.io/pypi/v/focus-cfe.svg?color=brightgreen\n :target: https://pypi.org/project/focus-cfe/\n :alt: PyPI version\n\n.. image:: https://readthedocs.org/projects/focus-cfe/badge/?version=latest\n :target: https://focus-cfe.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation status\n\n.. image:: https://pepy.tech/badge/focus-cfe\n :target: https://pepy.tech/project/focus-cfe\n :alt: Downloads\n\n.. image:: https://codecov.io/gh/kyosek/focus/branch/master/graph/badge.svg?token=G5I7TJR0JQ\n :target: https://codecov.io/gh/kyosek/focus\n\n.. image:: https://dl.circleci.com/status-badge/img/gh/kyosek/focus/tree/master.svg?style=svg\n :target: https://dl.circleci.com/status-badge/redirect/gh/kyosek/focus/tree/master\n :alt: Circle CI\n\n.. image:: https://api.codeclimate.com/v1/badges/93840d29606abb212051/maintainability\n :target: https://codeclimate.com/github/kyosek/focus-cfe/maintainability\n :alt: Maintainability\n\n.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\n :target: https://github.com/kyosek/focus-cfe\n :alt: pre-commit\n\n.. image:: https://img.shields.io/github/license/kyosek/focus.svg\n :target: https://github.com/kyosek/focus/blob/master/LICENSE\n :alt: License\n\n-----\n\nThis library is an implementation of `FOCUS: Flexible Optimizable Counterfactual Explanations for Tree Ensembles <https://arxiv.org/abs/1911.12199>`_.\n\nFOCUS generates optimal distance counterfactual explanations to the original data for all the instances in tree\u2010based machine learning models.\n\n**FOCUS counterfactual explanation generation with 3 Lines of Code**\\ :\n\n.. code-block:: python\n\n from focus import Focus\n # Initialize Focus instance with default values\n focus = Focus()\n # Generate counterfactual explanations for given tree model and features\n pertubed = focus.generate(tree_model, X)\n\n\n**Examples**\\:\n\n- More comprehensive example can be found in the `examples folder <https://github.com/kyosek/focus/blob/master/examples/focus_example.py>`_.\n- Another example in a kaggle notebook can be found `here <https://www.kaggle.com/code/kyosukemorita/focus-cfe-example>`_.\n- Below demonstrates the comparison of before and after FOCUS was applied to feature set from the above example.\n\n.. image:: docs/plot.png\n :width: 200px\n :height: 100px\n :scale: 50 %\n :alt: Before and After FOCUS was applied to the features from above example.\n\n**Limitations**\\:\n\n- Currently, FOCUS can only be applied to scikit-learn `DecisionTreeClassifier`, `RandomForestClassifier` and `AdaBoostClassifier`.\n- 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.\n- 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.\n\n^^^^^^^^^^^^\n\nIt is recommended to use **pip** or **conda** for installation. Please make sure\n**the latest version** is installed:\n\n.. code-block:: bash\n\n pip install focus-cfe # normal install\n pip install --upgrade focus-cfe # or update if needed\n\n.. code-block:: bash\n\n conda install -c conda-forge focus-cfe",
"bugtrack_url": null,
"license": "",
"summary": "FOCUS is a python package for generating counterfactual explanations for a tree-based model",
"version": "0.0.dev3",
"project_urls": null,
"split_keywords": [
"python",
"counterfactual explanation",
"binary classification",
"machine learning"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "888f70ffb687432922d2fd3574d762655c50dbab51c6cf60aab59c1a21d7db97",
"md5": "cee018e399aec6095238f107ea906dac",
"sha256": "35e226a2d635d7e20dfbdd057481728cc50d6ee02456e4312cacb0b694296713"
},
"downloads": -1,
"filename": "focus-cfe-0.0.dev3.tar.gz",
"has_sig": false,
"md5_digest": "cee018e399aec6095238f107ea906dac",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 13154,
"upload_time": "2023-07-22T18:21:16",
"upload_time_iso_8601": "2023-07-22T18:21:16.167629Z",
"url": "https://files.pythonhosted.org/packages/88/8f/70ffb687432922d2fd3574d762655c50dbab51c6cf60aab59c1a21d7db97/focus-cfe-0.0.dev3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-22 18:21:16",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "focus-cfe"
}