{"id":13673053,"url":"https://github.com/andreArtelt/ceml","last_synced_at":"2025-04-28T08:33:41.437Z","repository":{"id":39736710,"uuid":"196404546","full_name":"andreArtelt/ceml","owner":"andreArtelt","description":"CEML - Counterfactuals for Explaining Machine Learning models - A Python toolbox","archived":false,"fork":false,"pushed_at":"2024-07-27T17:45:24.000Z","size":269,"stargazers_count":42,"open_issues_count":2,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-03T16:50:54.510Z","etag":null,"topics":["counterfactual-explanations","explainable-ai","machine-learning","python","xai"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreArtelt.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-11T13:53:35.000Z","updated_at":"2024-08-03T02:39:51.000Z","dependencies_parsed_at":"2023-01-22T02:37:02.226Z","dependency_job_id":"1c656d6c-8899-49c0-9fdb-62127850a45a","html_url":"https://github.com/andreArtelt/ceml","commit_stats":{"total_commits":131,"total_committers":3,"mean_commits":"43.666666666666664","dds":0.06870229007633588,"last_synced_commit":"f1e474cb31bacfa950673c14f64057b2c7671dc7"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreArtelt%2Fceml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreArtelt%2Fceml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreArtelt%2Fceml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreArtelt%2Fceml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreArtelt","download_url":"https://codeload.github.com/andreArtelt/ceml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224103310,"owners_count":17256344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["counterfactual-explanations","explainable-ai","machine-learning","python","xai"],"created_at":"2024-08-02T10:00:23.108Z","updated_at":"2024-11-11T12:30:36.571Z","avatar_url":"https://github.com/andreArtelt.png","language":"Python","funding_links":[],"categories":["Github Repos","Libraries"],"sub_categories":[],"readme":"****\nCEML\n****\n--------------------------------------------------------\nCounterfactuals for Explaining Machine Learning models\n--------------------------------------------------------\n\nCEML is a Python toolbox for computing counterfactuals. Counterfactuals can be used to explain the predictions of machine learing models.\n\nIt supports many common machine learning frameworks:\n\n    - scikit-learn (1.5.0)\n    - PyTorch (2.0.1)\n    - Keras \u0026 Tensorflow (2.13.1)\n\nFurthermore, CEML is easy to use and can be extended very easily. See the following user guide for more information on how to use and extend CEML.\n\n.. image:: docs/_static/cf_illustration.png\n\nInstallation\n------------\n\n**Note: Python 3.8 is required!**\n\nTested on Ubuntu -- note that some people reported problems with some dependencies on Windows!\n\nPyPI\n++++\n\n.. code-block:: bash\n\n    pip install ceml\n\n**Note**: The package hosted on PyPI uses the cpu only. If you want to use the gpu, you have to install CEML manually - see next section.\n\nGit\n+++\nDownload or clone the repository:\n\n.. code:: bash\n\n    git clone https://github.com/andreArtelt/ceml.git\n    cd ceml\n\nInstall all requirements (listed in ``requirements.txt``):\n\n.. code:: bash\n\n    pip install -r requirements.txt\n\n**Note**: If you want to use a gpu/tpu, you have to install the gpu version of jax, tensorflow and pytorch manually. Do not use ``pip install -r requirements.txt``.\n\nInstall the toolbox itself:\n\n.. code:: bash\n\n    pip install .\n\n\nQuick example\n-------------\n\n.. code-block:: python\n\n    #!/usr/bin/env python3\n    # -*- coding: utf-8 -*-\n    from sklearn.datasets import load_iris\n    from sklearn.model_selection import train_test_split\n    from sklearn.metrics import accuracy_score\n    from sklearn.tree import DecisionTreeClassifier\n\n    from ceml.sklearn import generate_counterfactual\n\n\n    if __name__ == \"__main__\":\n        # Load data\n        X, y = load_iris(return_X_y=True)\n        X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=4242)\n\n        # Whitelist of features - list of features we can change/use when computing a counterfactual \n        features_whitelist = None   # We can use all features\n\n        # Create and fit model\n        model = DecisionTreeClassifier(max_depth=3)\n        model.fit(X_train, y_train)\n\n        # Select data point for explaining its prediction\n        x = X_test[1,:]\n        print(\"Prediction on x: {0}\".format(model.predict([x])))\n\n        # Compute counterfactual\n        print(\"\\nCompute counterfactual ....\")\n        print(generate_counterfactual(model, x, y_target=0, features_whitelist=features_whitelist))\n\nDocumentation\n-------------\n\nDocumentation is available on readthedocs:`https://ceml.readthedocs.io/en/latest/ \u003chttps://ceml.readthedocs.io/en/latest/\u003e`_\n\nLicense\n-------\n\nMIT license - See `LICENSE \u003cLICENSE\u003e`_\n\nHow to cite?\n------------\n    You can cite CEML by using the following BibTeX entry:\n\n    .. code-block::\n\n        @misc{ceml,\n                author = {André Artelt},\n                title = {CEML: Counterfactuals for Explaining Machine Learning models - A Python toolbox},\n                year = {2019 - 2023},\n                publisher = {GitHub},\n                journal = {GitHub repository},\n                howpublished = {\\url{https://www.github.com/andreArtelt/ceml}}\n            }\n\n\nThird party components\n----------------------\n\n    - `numpy \u003chttps://github.com/numpy/numpy\u003e`_\n    - `scipy \u003chttps://github.com/scipy/scipy\u003e`_\n    - `jax \u003chttps://github.com/google/jax\u003e`_\n    - `cvxpy \u003chttps://github.com/cvxgrp/cvxpy\u003e`_\n    - `scikit-learn \u003chttps://github.com/scikit-learn/scikit-learn\u003e`_\n    - `sklearn-lvq \u003chttps://github.com/MrNuggelz/sklearn-lvq\u003e`_\n    - `PyTorch \u003chttps://github.com/pytorch/pytorch\u003e`_\n    - `tensorflow \u003chttps://github.com/tensorflow\u003e`_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FandreArtelt%2Fceml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FandreArtelt%2Fceml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FandreArtelt%2Fceml/lists"}