Zuffy is a sklearn compatible open source python library for explainable machine learning through Fuzzy Pattern Trees
Project description
Zuffy - Fuzzy Pattern Trees with Genetic Programming |
A Scikit-learn compatible Open Source library for introducing FPTs as an Explainability Tool
(NOTE THAT THIS PROJECT IS UNDER DEVELOPMENT AND LIKELY TO CHANGE SIGNIFICANTLY UNTIL THE FIRST RELEASE. USE AT YOUR OWN RISK.)
Zuffy is an open source python library for explainable machine learning models. It is compatible with scikit-learn.
It aims to provide a simple set of tools for the exploration of FPTs that are inferred using genetic programming techniques.
Refer to the documentation for further information.
Setup
It may work with other versions but Zuffy has been tested with Python 3.11.9 and these library versions:
| Library | Version |
|---|---|
| sklearn | 1.5.2* |
| numpy | 1.26.4 |
| pandas | 2.2.1 |
| matplotlib | 3.9.2 |
| gplearn | 0.4.2 |
Note that Scikit-learn version 1.6+ modified the API around its "tags" and, until the authors update all their estimators, Zuffy will not run with version 1.6+.
To display the FPT you will need to install graphviz:
Unix
sudo apt install graphviz
$ sudo apt install graphviz
Windows
???
Installation
Clone the repository:
git clone https://github.com/pxom/zuffy.git Install the required dependencies: pip install -r requirements.txt
Resources
Documentation <https://zuffy.readthedocs.io/en/latest/?badge=latest>_Source Code <https://github.com/zuffy-dev/zuffy/>_Installation <https://github.com/zuffy-dev/zuffy#installation>_
Examples
To see more elaborate examples, look here.
import pandas as pd
from sklearn.datasets import load_iris
from zuffy import ZuffyClassifier, functions, visuals
from zuffy.wrapper import ZuffyFitIterator
iris = load_iris()
dataset = pd.DataFrame(data=iris.data, columns=iris.feature_names)
dataset['target'] = iris.target
targetNames = iris.target_names
X = dataset.iloc[:,0:-1]
y = dataset.iloc[:,-1]
fuzzy_X, fuzzy_features_names = functions.fuzzify_data(X)
zuffy = ZuffyClassifier(generations=15, verbose=1)
res = ZuffyFitIterator(zuffy, fuzzy_X, y, n_iter=3, split_at=0.25)
visuals.plot_evolution(
res.getBestEstimator(),
targetNames,
res.getPerformance(),
outputFilename='sample1_analysis')
visuals.graphviz_tree(
res.getBestEstimator(),
targetNames,
featureNames=fuzzy_features_names,
treeName=f"Iris Dataset (best accuracy: {res.getBestScore():.3f})",
outputFilename='sample1_fpt')
* TBD *
In an sklearn Pipeline <https://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html>_:
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
pipe = Pipeline([
('scale', StandardScaler()),
('net', net),
])
pipe.fit(X, y)
y_proba = pipe.predict_proba(X)
How to cite Zuffy
Authors of scientific papers including results generated using Zuffy are asked to cite the following paper.
@article{ZUFFY_1,
author = "POM",
title = { {Zuffy}: Open Source inference of FPT using GP },
pages = { 0--0 },
volume = { 1 },
month = { Apr },
year = { 2025 },
journal = { Journal of Unknown }
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zuffy-0.2.tar.gz.
File metadata
- Download URL: zuffy-0.2.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d99eb38ae3d84a49c8d363046e6710d5d9c6fbc304e1b43cc11fd5330b8d5354
|
|
| MD5 |
4f67dc364e50805dc41c109501347548
|
|
| BLAKE2b-256 |
1acb52b10762c433ca9b4ed30a619564e70d0a98c3b5fbc28cfcbc00c0d9cd83
|
File details
Details for the file zuffy-0.2-py3-none-any.whl.
File metadata
- Download URL: zuffy-0.2-py3-none-any.whl
- Upload date:
- Size: 29.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72e1d45cf61311c68b3e554d4283342a3082e4af25dde9b31458212d56170080
|
|
| MD5 |
85ea8db88b241358338598ed35f9147f
|
|
| BLAKE2b-256 |
146f35f6e3d573c8cf59758b5803cda93d4afad6006cea466e07ddd8e3c463f2
|
File details
Details for the file zuffy-0.2-1-py3-none-any.whl.
File metadata
- Download URL: zuffy-0.2-1-py3-none-any.whl
- Upload date:
- Size: 32.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b4c0d24bdd22f2c78c8cfb4e921f670273341725856a7fb3d9feb854bf51777
|
|
| MD5 |
4dfbad2cb732f2568c669e1f82f6b172
|
|
| BLAKE2b-256 |
9da50d7965a1c7db9216213fba09e3997fd74c07db485b5afe66f8ff7ec7f604
|