fuzzytool 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fuzzytool/__init__.py +55 -0
- fuzzytool/anfis.py +141 -0
- fuzzytool/cluster.py +231 -0
- fuzzytool/datasets.py +104 -0
- fuzzytool/defuzz.py +84 -0
- fuzzytool/ftransform.py +79 -0
- fuzzytool/inference/__init__.py +6 -0
- fuzzytool/inference/mamdani.py +93 -0
- fuzzytool/inference/tsk.py +77 -0
- fuzzytool/membership.py +149 -0
- fuzzytool/norms.py +105 -0
- fuzzytool/rules.py +34 -0
- fuzzytool/sets.py +210 -0
- fuzzytool/type2/__init__.py +27 -0
- fuzzytool/type2/inference.py +122 -0
- fuzzytool/type2/reduction.py +83 -0
- fuzzytool/type2/sets.py +96 -0
- fuzzytool/viz.py +118 -0
- fuzzytool-0.1.0.dist-info/METADATA +126 -0
- fuzzytool-0.1.0.dist-info/RECORD +22 -0
- fuzzytool-0.1.0.dist-info/WHEEL +4 -0
- fuzzytool-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fuzzytool
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A clean, extensible fuzzy-logic toolkit in pure Python + NumPy
|
|
5
|
+
Project-URL: Homepage, https://fuzzytool.github.io
|
|
6
|
+
Project-URL: Documentation, https://fuzzytool.github.io
|
|
7
|
+
Project-URL: Repository, https://github.com/fuzzytool/fuzzytool.github.io
|
|
8
|
+
Project-URL: Issues, https://github.com/fuzzytool/fuzzytool.github.io/issues
|
|
9
|
+
Author: Jose L. Salmeron
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: anfis,fuzzy inference,fuzzy logic,mamdani,takagi-sugeno,type-2
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Requires-Dist: numpy>=1.21
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
24
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
25
|
+
Provides-Extra: docs
|
|
26
|
+
Requires-Dist: mkdocs-material; extra == 'docs'
|
|
27
|
+
Requires-Dist: mkdocstrings[python]; extra == 'docs'
|
|
28
|
+
Provides-Extra: notebooks
|
|
29
|
+
Requires-Dist: ipykernel; extra == 'notebooks'
|
|
30
|
+
Requires-Dist: jupyter; extra == 'notebooks'
|
|
31
|
+
Requires-Dist: matplotlib>=3.4; extra == 'notebooks'
|
|
32
|
+
Requires-Dist: nbconvert; extra == 'notebooks'
|
|
33
|
+
Requires-Dist: nbformat; extra == 'notebooks'
|
|
34
|
+
Provides-Extra: viz
|
|
35
|
+
Requires-Dist: matplotlib>=3.4; extra == 'viz'
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
<p align="center">
|
|
39
|
+
<a href="https://pypi.org/project/fuzzytool/"><img src="https://img.shields.io/pypi/v/fuzzytool?logo=pypi&logoColor=white" alt="PyPI"></a>
|
|
40
|
+
<a href="https://github.com/fuzzytool/fuzzytool.github.io/actions/workflows/ci.yml"><img src="https://github.com/fuzzytool/fuzzytool.github.io/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
41
|
+
<a href="https://fuzzytool.github.io/"><img src="https://img.shields.io/badge/docs-fuzzytool.github.io-3f51b5" alt="Docs"></a>
|
|
42
|
+
<img src="https://img.shields.io/pypi/pyversions/fuzzytool?logo=python&logoColor=white" alt="Python versions">
|
|
43
|
+
<img src="https://img.shields.io/badge/license-MIT-blue" alt="License: MIT">
|
|
44
|
+
</p>
|
|
45
|
+
|
|
46
|
+
# fuzzytool
|
|
47
|
+
|
|
48
|
+
A clean, **extensible fuzzy-logic toolkit** in **pure Python + NumPy**. Its
|
|
49
|
+
design priorities are a composable API, algorithm comparison, visualization and
|
|
50
|
+
code clarity — a modern alternative to the verbose control API of scikit-fuzzy.
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
import fuzzytool as fz
|
|
54
|
+
|
|
55
|
+
# Credit-risk premium: a lender turns a credit score + debt-to-income ratio
|
|
56
|
+
# into the risk points it adds on top of its base interest rate.
|
|
57
|
+
score = fz.Variable("score", (300, 850), terms=["poor", "fair", "good", "excellent"])
|
|
58
|
+
dti = fz.Variable("dti", (0, 50), terms=["low", "moderate", "high"])
|
|
59
|
+
premium = fz.Variable("premium", (0, 12), terms=["low", "medium", "high"])
|
|
60
|
+
|
|
61
|
+
sys = fz.Mamdani(defuzz="centroid")
|
|
62
|
+
sys.rule(score["poor"] | dti["high"], premium["high"]) # |=OR &=AND ~=NOT
|
|
63
|
+
sys.rule(score["fair"] & dti["moderate"], premium["medium"])
|
|
64
|
+
sys.rule(score["good"] | score["excellent"], premium["low"])
|
|
65
|
+
|
|
66
|
+
print(sys(score=800, dti=10)) # the system is just callable -> a low premium
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## The design idea (extensibility)
|
|
70
|
+
|
|
71
|
+
The inference loop knows **nothing** about any concrete variant. Everything that
|
|
72
|
+
changes lives behind small Python **Protocols**:
|
|
73
|
+
|
|
74
|
+
- **`MembershipFunction`** (`fuzzytool/membership.py`) — a callable `x -> degree`.
|
|
75
|
+
A new shape = a new callable.
|
|
76
|
+
- **`Norm`** (`fuzzytool/norms.py`) — t-norms (AND) and s-norms (OR), resolved by
|
|
77
|
+
name. A new connective = one registered function.
|
|
78
|
+
- **defuzzifiers** (`fuzzytool/defuzz.py`) — centroid, bisector, MOM/SOM/LOM,
|
|
79
|
+
resolved by name.
|
|
80
|
+
|
|
81
|
+
Rules read like logic thanks to operator overloading: `&` is the t-norm, `|` the
|
|
82
|
+
s-norm, `~` the complement.
|
|
83
|
+
|
|
84
|
+
## What it includes / roadmap
|
|
85
|
+
|
|
86
|
+
| Phase | Content | Status |
|
|
87
|
+
|------|-----------|--------|
|
|
88
|
+
| 1 | Core: membership functions, t-/s-norms, `Variable`, operator rules, **Mamdani** + defuzzification, tipper example, tests | ✅ |
|
|
89
|
+
| 2 | **Takagi-Sugeno (TSK)** inference + `viz` (membership plots, control surface) | ✅ (TSK + viz) |
|
|
90
|
+
| 3 | **Type-2 / interval type-2** sets (footprint of uncertainty) + Karnik-Mendel type reduction | ✅ |
|
|
91
|
+
| 4 | **Fuzzy clustering**: fuzzy c-means, Gustafson-Kessel, possibilistic | ✅ |
|
|
92
|
+
| 5 | **ANFIS** (trainable TSK) + **F-transform** (direct/inverse) | ✅ |
|
|
93
|
+
| 6 | Notebooks, JOSS `paper.md`, Zenodo DOI, PyPI release | ⏳ |
|
|
94
|
+
|
|
95
|
+
See [`ROADMAP.md`](ROADMAP.md).
|
|
96
|
+
|
|
97
|
+
## Install
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pip install fuzzytool # core (NumPy only)
|
|
101
|
+
pip install fuzzytool[viz] # + matplotlib visualization
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
From source, for development:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
python -m venv .venv && source .venv/bin/activate
|
|
108
|
+
pip install -e ".[dev,viz,docs]"
|
|
109
|
+
pytest -q
|
|
110
|
+
python examples/tipper.py
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Documentation
|
|
114
|
+
|
|
115
|
+
A documentation portal (narrative guide + API reference from docstrings) is built
|
|
116
|
+
with **MkDocs Material** and published to **GitHub Pages**:
|
|
117
|
+
<https://fuzzytool.github.io/>.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
pip install -e ".[docs]"
|
|
121
|
+
mkdocs serve # live portal at http://127.0.0.1:8000
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT. See [`LICENSE`](LICENSE).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
fuzzytool/__init__.py,sha256=l8b2zG9RUvyzK6BgLgYREI0AOZF381c7_jTvc7dOvqE,1879
|
|
2
|
+
fuzzytool/anfis.py,sha256=6z5447OH_QewKrq9aruS67xlJKyXRbUDc9ejao-gAqI,6271
|
|
3
|
+
fuzzytool/cluster.py,sha256=nmvlEhyID4I4ezLrUvaXKclm59tDzJEiA9mTYVk8zDY,8187
|
|
4
|
+
fuzzytool/datasets.py,sha256=2xy4eUtka_Q19VNNplXIsu0ebFYFgYERt2EJuilG_Sc,3768
|
|
5
|
+
fuzzytool/defuzz.py,sha256=BWNIVL-P-uSoN8fhmFW8fU0c_h2GYOO3FsvZ1c_hgsI,2500
|
|
6
|
+
fuzzytool/ftransform.py,sha256=TtHzhn1ALQuyvpx-wts6LkpYBHVSdGj7zSvWZ2gD5ms,2976
|
|
7
|
+
fuzzytool/membership.py,sha256=g8frbFTo7PCrzczCbdLfi_4Zl9aXvOz3Ma091ZbQY0Q,5214
|
|
8
|
+
fuzzytool/norms.py,sha256=_uBvWslpMA8NiTM-_plAFaoDcJeeXXd_XkMs86rRYYo,2678
|
|
9
|
+
fuzzytool/rules.py,sha256=63u5sUqi-R78eemyVy8VIzly-l7CnrvPPLlyyspJC_Y,966
|
|
10
|
+
fuzzytool/sets.py,sha256=FmvzP_KX4scelCXG6Sov42WvyAWIcqb7hx8bJdtIENA,7864
|
|
11
|
+
fuzzytool/viz.py,sha256=FBpvSG_sFC9fX7-_L2Ib4deTgYgZ4Hsm2_MLexYYIGg,4026
|
|
12
|
+
fuzzytool/inference/__init__.py,sha256=d1IvwMUQ7DKy53zZJT4ER3OVIVrcmNk2HlGqv0yOHG4,112
|
|
13
|
+
fuzzytool/inference/mamdani.py,sha256=-j46PC80ZBIrXMCGD1PQabWmW3teaLpAqp3_opJT0nU,3691
|
|
14
|
+
fuzzytool/inference/tsk.py,sha256=eJ_c2LnQkkvVDOKaV6IMP2XzzkxRgFxWh96hx7xptqQ,2720
|
|
15
|
+
fuzzytool/type2/__init__.py,sha256=t9j46DuP317_THKCEZpBJzRR8GlQfGwv4XCGjYkklLE,972
|
|
16
|
+
fuzzytool/type2/inference.py,sha256=tUTKFzwV_mHoRERrjIcxxtdPH0m0Cshep2JEBik0ec0,5098
|
|
17
|
+
fuzzytool/type2/reduction.py,sha256=kKzBcq-8Ob-oOzX3c_OL4Kzh-FNSxf8RtBYmN28xotw,3046
|
|
18
|
+
fuzzytool/type2/sets.py,sha256=dekOs6SCExHKD9xcDE8FmHFbkB5qmBQqBEHbenwPjbE,3558
|
|
19
|
+
fuzzytool-0.1.0.dist-info/METADATA,sha256=EAlXtENPTHsBI1w1pwCIpTgqhloIQwjeuClgmv4vvTg,5156
|
|
20
|
+
fuzzytool-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
21
|
+
fuzzytool-0.1.0.dist-info/licenses/LICENSE,sha256=ZZJGlkdgWur4Vvv8cAZI_xYZKnOB9rI2jV5nkNJXn7w,1073
|
|
22
|
+
fuzzytool-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jose L. Salmeron
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|