RuleXAI
RuleXAI is a rule-based aproach to explain the output of any machine learning model. It is suitable for classification, regression and survival tasks.
Instalation
RuleXAI can be installed from PyPI
pip install rulexai
Or you can clone the repository and run:
pip install .
Model agnostic example
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
import pandas as pd
from rulexai.explainer import Explainer
# load iris dataset
data = load_iris()
df = pd.DataFrame(data['data'], columns=data['feature_names'])
df['class'] = data['target']
# train a SVM classifier
X_train,X_test,y_train,y_test = train_test_split(df.drop(columns=["class"]), df["class"], test_size=0.2, random_state=0)
svm = SVC(kernel='rbf', probability=True)
svm.fit(X_train, y_train)
predictions = svm.predict(X_train)
# prepare model predictions to be fed to RuleXAI, remember to change numerical predictions to labels (in this example it is simply converting predictions to a string)
model_predictions = pd.DataFrame(predictions.astype(str), columns=[y_train.name], index = y_train.index)
# use Explainer to explain model output
explainer = Explainer(X = X_train,model_predictions = model_predictions, type = "classification")
explainer.explain()
print(explainer.condition_importances_)
Sample notebooks
-
Classification - in this notebook, the data from https://www.kaggle.com/c/titanic is analysed to show the advantages and possibilities of using the RuleXAI library for in-depth analysis of the dataset for classification task. The use of RuleXAI to explain rule-based and tree-based models was also compared.
-
Regression - notebook showing the use of RuleXAI to explain rule-based regression model
-
Survival - notebook showing the use of RuleXAI to explain rule-based survival model
-
Black-box model explainability - the purpose of this notebook is to demonstrate the possibility of using RuleXAI to explain any black box models.
-
Transformation - notebook showing the use of RuleXAI to transform a dataset. Often datasets contain missing values and nominal values. Most available algorithms do not support either missing values or nominal values. Many algorithms require the data to be rescaled beforehand. The RuleXAI library is able to convert a dataset with nominal and missing values into a binary dataset containing as attributes the conditions describing the dataset and as values “1” when the condition is satisfied for the example and “0” when the condition is not satisfied.
Documentation
Full documentation is available here
Metadata
Release files for rulexai 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rulexai-1.1.0.tar.gz | 31.7 kB | Without provenance | Details for rulexai-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rulexai-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for rulexai-1.1.0-py3-none-any.whl |
Total release size: 62.0 kB
Release files / rulexai-1.1.0.tar.gz
| Download URL | rulexai-1.1.0.tar.gz |
|---|---|
| Size | 31.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d1b26e0a9fd870b532759482e051ebcf3f50c56f45c71a0225d65c723c28815
|
|
BLAKE2b-256 checksum How to use checksums |
98d46ce99d9fd930fe75125d2e894a79af94b1a257263a473d891cd98e0bbd13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.8
|
Release files / rulexai-1.1.0-py3-none-any.whl
| Download URL | rulexai-1.1.0-py3-none-any.whl |
|---|---|
| Size | 30.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
02e8f47ded50bad90dce2c9cb316a3ba2b8d651011d0b91cfb427f747c59a992
|
|
BLAKE2b-256 checksum How to use checksums |
aa58fc3309b54cac9164c218bd89d9aab5fd85793cb032fc5d53e0a4e3d3fdcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.8
|
Security for rulexai 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.