Skip to main content

Explaining Machine Learning Classifiers in Python

Project description

PyXAI v1 BETA (September 27, 2022)

PyXAI is a library in Python 3 (version 3.6 or later) allowing to bring explanations of various forms through reasons (sufficient, majoritary, contrastive, ...) from classifiers resulting of machine learning techniques (Decision Tree, Random Forest, Boosted Tree).

Installation

Installation from PyPi

The Python Package Index (PyPi) is the easiest way of installing PyXAI.

Note that you need first Python 3 (version 3.6, or later) to be installed. You can do it, for example, from python.org

Installing PyXAI (Linux)

Check if 'python3-pip' is installed. If it is not the case, execute:

sudo apt install python3-pip

Or check if you have the last installed version:

python3 -m pip install --upgrade pip

Then, install PyXAI with the command 'pip3':

python3 -m pip install pyxai

Installing PyXAI (Mac OS)

PyXAI is currently compatible with Mac OS but without PyPi, see the installation (alternative) by Cloning from GitHub section for more details.

Installing PyXAI (Windows)

PyXAI is currently not compatible with windows (works in progress).

Updating the Version of PyXAI (for PyPi)

For updating your version of PyXAI, simply execute:

For linux/Mac:

python3 -m pip install -U pyxai

Installation (alternative) by Cloning from GitHub

An alternative to PyPi is to clone the code from GitHub.

Here is an illustration for linux. We assume that Python 3 is installed, and consequently 'pip3' is also installed. In a console, type:

git clone https://gitlab.univ-artois.fr/expekctation/software/PyLearningExplanation.git

You may need to update the environment variable 'PYTHONPATH', by typing for example:

export PYTHONPATH="${PYTHONPATH}:${PWD}/.."

Get the last version of pip:

python3 -m pip install --upgrade pip

There are a few packages that PyXAI depends on that must be installed:

python3 -m pip install numpy
python3 -m pip install wheel
python3 -m pip install pandas
python3 -m pip install termcolor
python3 -m pip install shap
python3 -m pip install wordfreq
python3 -m pip install python-sat[pblib,aiger]
python3 -m pip install xgboost
python3 -m pip install lxml
python3 -m pip install pycsp3
python3 -m pip install matplotlib

To compile the c++ code (python C extensions):

python3 setup.py install --user

Of course, for this step, you need a C++ compiler.

Unfortunately, the compiled C extensions are not take into account in a virtual environment, therefore you must type (we consider here that the virtual environment is in the 'env' directory and you are in the 'PyXAI' directory):

cp build/lib.linux-x86_64-3.6/c_explainer.cpython-36m-x86_64-linux-gnu.so env/lib/python3.6/site-packages/.

This last command depend of your python version (here: 3.6).

Finally, you can test an example:

python3 examples/DT/BuilderOrchids.py 

Virtual Environment

Create and activate a new virtual environment:

sudo apt-get install python3.6-venv
python3.6 -m venv env
source env/bin/activate

Now you can do the "Installation from PyPi" or the "Installation (alternative) by Cloning from GitHub".

Note that if you want install dependencies without internet connection, you can build a requirement.txt file:

python3 -m pip freeze > requirements.txt 
python3 -m pip download -r requirements.txt -d requirements-download/
pip install -r requirements.txt --find-links=requirements-download --no-index

For deactivating the environment:

deactivate

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pyxai-0.0.0.10-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (627.3 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyxai-0.0.0.10-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (627.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyxai-0.0.0.10-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyxai-0.0.0.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (898.2 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyxai-0.0.0.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (897.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyxai-0.0.0.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (897.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyxai-0.0.0.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (896.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyxai-0.0.0.10-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (896.2 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pyxai-0.0.0.10-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (894.5 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page