CFXplorer


NameCFXplorer JSON
Version 0.1.0 PyPI version JSON
download
home_page
SummaryCFXplorer is a python package for generating counterfactual explanations for given model and feature set
upload_time2023-07-29 17:09:08
maintainer
docs_urlNone
authorKyosuke Morita
requires_python
license
keywords python counterfactual explanation binary classification machine learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            CFXplorer
=========

**Deployment & Documentation & Stats & License**

.. image:: https://img.shields.io/pypi/v/CFXplorer.svg?color=brightgreen
   :target: https://pypi.org/project/CFXplorer/
   :alt: PyPI version

.. image:: https://readthedocs.org/projects/CFXplorer/badge/?version=latest
   :target: https://CFXplorer.readthedocs.io/en/latest/?badge=latest
   :alt: Documentation status

.. image:: https://pepy.tech/badge/CFXplorer
   :target: https://pepy.tech/project/CFXplorer
   :alt: Downloads

.. image:: https://codecov.io/gh/kyosek/CFXplorer/branch/master/graph/badge.svg?token=G5I7TJR0JQ
    :target: https://codecov.io/gh/kyosek/CFXplorer
    :alt: Code Coverage

.. image:: https://dl.circleci.com/status-badge/img/gh/kyosek/CFXplorer/tree/master.svg?style=svg
    :target: https://dl.circleci.com/status-badge/redirect/gh/kyosek/CFXplorer/tree/master
    :alt: Circle CI

.. image:: https://api.codeclimate.com/v1/badges/93840d29606abb212051/maintainability
   :target: https://codeclimate.com/github/kyosek/CFXplorer/maintainability
   :alt: Maintainability

.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit
   :target: https://github.com/kyosek/CFXplorer
   :alt: pre-commit

.. image:: https://img.shields.io/github/license/kyosek/CFXplorer.svg
   :target: https://github.com/kyosek/CFXplorer/blob/master/LICENSE
   :alt: License

---------

CFXplorer generates optimal distance counterfactual explanations of the original data for the instances in treeā€based machine learning models.

This package is an implementation of `FOCUS: Flexible Optimizable Counterfactual Explanations for Tree Ensembles (Lucic, et at. 2022) <https://arxiv.org/abs/1911.12199>`_.

Installation
------------

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

.. code-block:: bash

   pip install CFXplorer            # normal install
   pip install --upgrade CFXplorer  # or update if needed

.. code-block:: bash

   conda install -c conda-forge CFXplorer

Requirements
------------

- Python 3.6+
- numpy>=1.19.1
- tensorflow>=2.0.0
- scikit-learn>=1.0.2

Usage
-----
**FOCUS counterfactual explanation generation with 3 Lines of Code**\ :

.. code-block:: python

    from cfxplorer 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
--------

- Comprehensive examples can be found in the `examples folder <https://github.com/kyosek/CFXplorer/blob/master/examples>`_.
- Kaggle notebook example can be found `here <https://www.kaggle.com/code/kyosukemorita/cfxplorer-example>`__.
- Below is demonstrated a comparison of before and after Focus is applied to feature set from the example given above.

.. image:: https://raw.githubusercontent.com/kyosek/focus/master/docs/plot.png
    :width: 800px
    :height: 400px
    :scale: 100 %
    :alt: Before and After FOCUS was applied to the features from above example.

Limitations of Focus class
--------------------------

- Currently, Focus class 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.

Documentation
-------------

The documentation can be found `here <https://cfxplorer.readthedocs.io/en/latest/>`__.

Contributing
------------

If you would like to contribute to the project, please refer to;

- `ISSUE_TEMPLATE <https://github.com/kyosek/CFXplorer/tree/master/.github/ISSUE_TEMPLATE>`_ for raising an issue
- `PULL_REQUEST_TEMPLATE.md <https://github.com/kyosek/CFXplorer/blob/master/.github/PULL_REQUEST_TEMPLATE.md>`_ for raising a PR

License
-------
This package is using the `Apache License 2.0 <https://github.com/kyosek/CFXplorer/blob/master/LICENSE>`_ license.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "CFXplorer",
    "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/33/90/3e2b5b2d135c8913885048b42a680a80d25bfd5f442809a729a3fce31fb7/CFXplorer-0.1.0.tar.gz",
    "platform": null,
    "description": "CFXplorer\n=========\n\n**Deployment & Documentation & Stats & License**\n\n.. image:: https://img.shields.io/pypi/v/CFXplorer.svg?color=brightgreen\n   :target: https://pypi.org/project/CFXplorer/\n   :alt: PyPI version\n\n.. image:: https://readthedocs.org/projects/CFXplorer/badge/?version=latest\n   :target: https://CFXplorer.readthedocs.io/en/latest/?badge=latest\n   :alt: Documentation status\n\n.. image:: https://pepy.tech/badge/CFXplorer\n   :target: https://pepy.tech/project/CFXplorer\n   :alt: Downloads\n\n.. image:: https://codecov.io/gh/kyosek/CFXplorer/branch/master/graph/badge.svg?token=G5I7TJR0JQ\n    :target: https://codecov.io/gh/kyosek/CFXplorer\n    :alt: Code Coverage\n\n.. image:: https://dl.circleci.com/status-badge/img/gh/kyosek/CFXplorer/tree/master.svg?style=svg\n    :target: https://dl.circleci.com/status-badge/redirect/gh/kyosek/CFXplorer/tree/master\n    :alt: Circle CI\n\n.. image:: https://api.codeclimate.com/v1/badges/93840d29606abb212051/maintainability\n   :target: https://codeclimate.com/github/kyosek/CFXplorer/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/CFXplorer\n   :alt: pre-commit\n\n.. image:: https://img.shields.io/github/license/kyosek/CFXplorer.svg\n   :target: https://github.com/kyosek/CFXplorer/blob/master/LICENSE\n   :alt: License\n\n---------\n\nCFXplorer generates optimal distance counterfactual explanations of the original data for the instances in tree\u2010based machine learning models.\n\nThis package is an implementation of `FOCUS: Flexible Optimizable Counterfactual Explanations for Tree Ensembles (Lucic, et at. 2022) <https://arxiv.org/abs/1911.12199>`_.\n\nInstallation\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 CFXplorer            # normal install\n   pip install --upgrade CFXplorer  # or update if needed\n\n.. code-block:: bash\n\n   conda install -c conda-forge CFXplorer\n\nRequirements\n------------\n\n- Python 3.6+\n- numpy>=1.19.1\n- tensorflow>=2.0.0\n- scikit-learn>=1.0.2\n\nUsage\n-----\n**FOCUS counterfactual explanation generation with 3 Lines of Code**\\ :\n\n.. code-block:: python\n\n    from cfxplorer import Focus\n    # Initialize Focus instance with default values\n    focus = Focus()\n\n    # Generate counterfactual explanations for given tree model and features\n    pertubed = focus.generate(tree_model, X)\n\nExamples\n--------\n\n- Comprehensive examples can be found in the `examples folder <https://github.com/kyosek/CFXplorer/blob/master/examples>`_.\n- Kaggle notebook example can be found `here <https://www.kaggle.com/code/kyosukemorita/cfxplorer-example>`__.\n- Below is demonstrated a comparison of before and after Focus is applied to feature set from the example given above.\n\n.. image:: https://raw.githubusercontent.com/kyosek/focus/master/docs/plot.png\n    :width: 800px\n    :height: 400px\n    :scale: 100 %\n    :alt: Before and After FOCUS was applied to the features from above example.\n\nLimitations of Focus class\n--------------------------\n\n- Currently, Focus class 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\nDocumentation\n-------------\n\nThe documentation can be found `here <https://cfxplorer.readthedocs.io/en/latest/>`__.\n\nContributing\n------------\n\nIf you would like to contribute to the project, please refer to;\n\n- `ISSUE_TEMPLATE <https://github.com/kyosek/CFXplorer/tree/master/.github/ISSUE_TEMPLATE>`_ for raising an issue\n- `PULL_REQUEST_TEMPLATE.md <https://github.com/kyosek/CFXplorer/blob/master/.github/PULL_REQUEST_TEMPLATE.md>`_ for raising a PR\n\nLicense\n-------\nThis package is using the `Apache License 2.0 <https://github.com/kyosek/CFXplorer/blob/master/LICENSE>`_ license.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "CFXplorer is a python package for generating counterfactual explanations for given model and feature set",
    "version": "0.1.0",
    "project_urls": null,
    "split_keywords": [
        "python",
        "counterfactual explanation",
        "binary classification",
        "machine learning"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5de3bfc9b4764b4dccdf90cfa3226b3c6f9e0d777d722fbb3f09162705e5fe12",
                "md5": "b96c3a4cfe60568adde331086e455a54",
                "sha256": "907f0a612a1871319946fcde9a4e96fedeef4d2aad3d3bae49a057037ac0a5f2"
            },
            "downloads": -1,
            "filename": "CFXplorer-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b96c3a4cfe60568adde331086e455a54",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 16727,
            "upload_time": "2023-07-29T17:16:34",
            "upload_time_iso_8601": "2023-07-29T17:16:34.395549Z",
            "url": "https://files.pythonhosted.org/packages/5d/e3/bfc9b4764b4dccdf90cfa3226b3c6f9e0d777d722fbb3f09162705e5fe12/CFXplorer-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "33903e2b5b2d135c8913885048b42a680a80d25bfd5f442809a729a3fce31fb7",
                "md5": "4ae929d4d02a338fb832604372071d20",
                "sha256": "76e0d5c35542863677154e67f8a332ec74b577b9f169fe35b05e617989275346"
            },
            "downloads": -1,
            "filename": "CFXplorer-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4ae929d4d02a338fb832604372071d20",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15611,
            "upload_time": "2023-07-29T17:09:08",
            "upload_time_iso_8601": "2023-07-29T17:09:08.648211Z",
            "url": "https://files.pythonhosted.org/packages/33/90/3e2b5b2d135c8913885048b42a680a80d25bfd5f442809a729a3fce31fb7/CFXplorer-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-29 17:09:08",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cfxplorer"
}
        
Elapsed time: 0.64452s