A clean, extensible fuzzy-logic toolkit in pure Python + NumPy
Project description
fuzzytool
A clean, extensible fuzzy-logic toolkit in pure Python + NumPy. Its design priorities are a composable API, algorithm comparison, visualization and code clarity — a modern alternative to the verbose control API of scikit-fuzzy.
import fuzzytool as fz
# Credit-risk premium: a lender turns a credit score + debt-to-income ratio
# into the risk points it adds on top of its base interest rate.
score = fz.Variable("score", (300, 850), terms=["poor", "fair", "good", "excellent"])
dti = fz.Variable("dti", (0, 50), terms=["low", "moderate", "high"])
premium = fz.Variable("premium", (0, 12), terms=["low", "medium", "high"])
sys = fz.Mamdani(defuzz="centroid")
sys.rule(score["poor"] | dti["high"], premium["high"]) # |=OR &=AND ~=NOT
sys.rule(score["fair"] & dti["moderate"], premium["medium"])
sys.rule(score["good"] | score["excellent"], premium["low"])
print(sys(score=800, dti=10)) # the system is just callable -> a low premium
The design idea (extensibility)
The inference loop knows nothing about any concrete variant. Everything that changes lives behind small Python Protocols:
MembershipFunction(fuzzytool/membership.py) — a callablex -> degree. A new shape = a new callable.Norm(fuzzytool/norms.py) — t-norms (AND) and s-norms (OR), resolved by name. A new connective = one registered function.- defuzzifiers (
fuzzytool/defuzz.py) — centroid, bisector, MOM/SOM/LOM, resolved by name.
Rules read like logic thanks to operator overloading: & is the t-norm, | the
s-norm, ~ the complement.
What it includes / roadmap
| Phase | Content | Status |
|---|---|---|
| 1 | Core: membership functions, t-/s-norms, Variable, operator rules, Mamdani + defuzzification, tipper example, tests |
✅ |
| 2 | Takagi-Sugeno (TSK) inference + viz (membership plots, control surface) |
✅ (TSK + viz) |
| 3 | Type-2 / interval type-2 sets (footprint of uncertainty) + Karnik-Mendel type reduction | ✅ |
| 4 | Fuzzy clustering: fuzzy c-means, Gustafson-Kessel, possibilistic | ✅ |
| 5 | ANFIS (trainable TSK) + F-transform (direct/inverse) | ✅ |
| 6 | Notebooks, JOSS paper.md, Zenodo DOI, PyPI release |
⏳ |
See ROADMAP.md.
Install
pip install fuzzytool # core (NumPy only)
pip install fuzzytool[viz] # + matplotlib visualization
From source, for development:
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,viz,docs]"
pytest -q
python examples/tipper.py
Documentation
A documentation portal (narrative guide + API reference from docstrings) is built with MkDocs Material and published to GitHub Pages: https://fuzzytool.github.io/.
pip install -e ".[docs]"
mkdocs serve # live portal at http://127.0.0.1:8000
License
MIT. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 fuzzytool-0.1.0.tar.gz.
File metadata
- Download URL: fuzzytool-0.1.0.tar.gz
- Upload date:
- Size: 384.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3ee3d958066fffa3e6133ba40206864bca606cc565a731aee4e7866d61d1cdb
|
|
| MD5 |
d1861b71c17c39d7f97505fc6310d497
|
|
| BLAKE2b-256 |
97814d51e3ae024b3ac8e43f155d8f0020817f8399b9d9ccca59fa6dd1e9795a
|
Provenance
The following attestation bundles were made for fuzzytool-0.1.0.tar.gz:
Publisher:
release-pypi.yml on fuzzytool/fuzzytool.github.io
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fuzzytool-0.1.0.tar.gz -
Subject digest:
f3ee3d958066fffa3e6133ba40206864bca606cc565a731aee4e7866d61d1cdb - Sigstore transparency entry: 1943260288
- Sigstore integration time:
-
Permalink:
fuzzytool/fuzzytool.github.io@3def3cdd83e9890885f51b04b30bc0470cd4150e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/fuzzytool
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@3def3cdd83e9890885f51b04b30bc0470cd4150e -
Trigger Event:
push
-
Statement type:
File details
Details for the file fuzzytool-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fuzzytool-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe517deaf914ed12707b5f021d3b14fcde739dfd1161adf6d30e0c50e00cee8b
|
|
| MD5 |
98afb35ca590fe2a87dbef9f58dcb4eb
|
|
| BLAKE2b-256 |
435e6b84fdb6bd1495eb817a7fd274e3b219d6f5cb34cd40a947b2e605174f95
|
Provenance
The following attestation bundles were made for fuzzytool-0.1.0-py3-none-any.whl:
Publisher:
release-pypi.yml on fuzzytool/fuzzytool.github.io
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fuzzytool-0.1.0-py3-none-any.whl -
Subject digest:
fe517deaf914ed12707b5f021d3b14fcde739dfd1161adf6d30e0c50e00cee8b - Sigstore transparency entry: 1943260771
- Sigstore integration time:
-
Permalink:
fuzzytool/fuzzytool.github.io@3def3cdd83e9890885f51b04b30bc0470cd4150e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/fuzzytool
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@3def3cdd83e9890885f51b04b30bc0470cd4150e -
Trigger Event:
push
-
Statement type: