fuzzytool 0.2.0__tar.gz → 0.4.0__tar.gz
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-0.2.0 → fuzzytool-0.4.0}/CHANGELOG.md +41 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/CITATION.cff +2 -2
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/PKG-INFO +44 -3
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/README.md +19 -2
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/ROADMAP.md +23 -3
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/api/python.md +28 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/getting-started.md +6 -2
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/guide/batch-and-io.md +1 -1
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/guide/clustering.md +2 -0
- fuzzytool-0.4.0/docs/guide/fraud-alert.md +65 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/guide/ftransform.md +1 -1
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/guide/mcdm.md +5 -5
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/guide/rule-learning.md +3 -3
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/guide/tsk.md +1 -1
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/guide/type2.md +12 -1
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/guide/visualization.md +4 -0
- fuzzytool-0.4.0/docs/images/clusters.png +0 -0
- fuzzytool-0.4.0/docs/images/credit_control_surface.png +0 -0
- fuzzytool-0.4.0/docs/images/fraud_anomaly_terms.png +0 -0
- fuzzytool-0.4.0/docs/images/fraud_control_surface.png +0 -0
- fuzzytool-0.4.0/docs/images/gs_score_terms.png +0 -0
- fuzzytool-0.4.0/docs/images/it2_score.png +0 -0
- fuzzytool-0.4.0/docs/images/premium_terms.png +0 -0
- fuzzytool-0.4.0/docs/images/tut_advisor_surface.png +0 -0
- fuzzytool-0.4.0/docs/images/tut_advisor_volatility.png +0 -0
- fuzzytool-0.4.0/docs/images/tut_anfis.png +0 -0
- fuzzytool-0.4.0/docs/images/tut_clusters.png +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/index.md +6 -0
- fuzzytool-0.4.0/docs/integrations.md +326 -0
- fuzzytool-0.4.0/docs/javascripts/mathjax.js +12 -0
- fuzzytool-0.4.0/docs/tutorials/anfis-learning.md +69 -0
- fuzzytool-0.4.0/docs/tutorials/clustering-segmentation.md +76 -0
- fuzzytool-0.4.0/docs/tutorials/risk-advisor.md +97 -0
- fuzzytool-0.4.0/docs/tutorials/topsis-decision.md +66 -0
- fuzzytool-0.4.0/examples/fraud_alert.py +39 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/__init__.py +1 -1
- fuzzytool-0.4.0/fuzzytool/integrations/__init__.py +14 -0
- fuzzytool-0.4.0/fuzzytool/integrations/_util.py +96 -0
- fuzzytool-0.4.0/fuzzytool/integrations/agents.py +96 -0
- fuzzytool-0.4.0/fuzzytool/integrations/optuna.py +107 -0
- fuzzytool-0.4.0/fuzzytool/integrations/pandas.py +116 -0
- fuzzytool-0.4.0/fuzzytool/integrations/parallel.py +156 -0
- fuzzytool-0.4.0/fuzzytool/integrations/scipy.py +105 -0
- fuzzytool-0.4.0/fuzzytool/integrations/sklearn.py +178 -0
- fuzzytool-0.4.0/fuzzytool/integrations/torch.py +116 -0
- fuzzytool-0.4.0/fuzzytool/integrations/turboswarm.py +120 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/mkdocs.yml +24 -2
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/pyproject.toml +12 -2
- fuzzytool-0.4.0/tests/test_integrations.py +301 -0
- fuzzytool-0.2.0/docs/comparison.md +0 -72
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/.github/workflows/ci.yml +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/.github/workflows/docs.yml +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/.github/workflows/release-pypi.yml +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/.gitignore +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/.zenodo.json +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/CLAUDE.md +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/CONTRIBUTING.md +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/LICENSE +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/citing.md +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/extending.md +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/guide/anfis.md +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/guide/defuzzification.md +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/guide/mamdani.md +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/guide/membership.md +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/guide/rules.md +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/docs/installation.md +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/examples/anfis.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/examples/clustering.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/examples/credit_risk.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/examples/credit_risk_it2.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/examples/ftransform.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/examples/mcdm.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/anfis.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/cluster.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/datasets.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/defuzz.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/ftransform.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/fuzzynum.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/inference/__init__.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/inference/mamdani.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/inference/tsk.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/inference/tsukamoto.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/learn.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/mcdm.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/membership.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/norms.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/rules.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/serialize.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/sets.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/type2/__init__.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/type2/inference.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/type2/reduction.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/type2/sets.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/fuzzytool/viz.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/notebooks/01_quickstart.ipynb +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/notebooks/02_type2.ipynb +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/notebooks/03_clustering.ipynb +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/notebooks/04_learning.ipynb +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/notebooks/README.md +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/paper.bib +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/paper.md +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/tests/test_cluster.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/tests/test_engineering.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/tests/test_inference.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/tests/test_learn.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/tests/test_learning.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/tests/test_mcdm.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/tests/test_membership.py +0 -0
- {fuzzytool-0.2.0 → fuzzytool-0.4.0}/tests/test_type2.py +0 -0
|
@@ -6,6 +6,47 @@ All notable changes to this project are documented here. The format is based on
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.4.0] - 2026-06-28
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **turboswarm integration** (`fuzzytool.integrations.turboswarm`, extra
|
|
14
|
+
`[turboswarm]`): `tune` fits a system's built-in membership-function
|
|
15
|
+
parameters to data with the sibling library's gradient-free, global Particle
|
|
16
|
+
Swarm Optimization — the metaheuristic counterpart of the SciPy least-squares
|
|
17
|
+
tuner. Returns turboswarm's `PsoResult`.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Shared membership-function tuning helpers (`sanitize_mf_params`,
|
|
22
|
+
`tunable_terms`, `MF_PENALTY`) moved to `fuzzytool.integrations._util` and
|
|
23
|
+
reused by both the SciPy and turboswarm tuners.
|
|
24
|
+
|
|
25
|
+
## [0.3.0] - 2026-06-27
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- **Ecosystem integrations** under `fuzzytool.integrations.*` — each behind its
|
|
30
|
+
own extra and importing its dependency only on use, so the core stays pure
|
|
31
|
+
NumPy:
|
|
32
|
+
- **pandas** (`[pandas]`): `predict_df`, `rules_dataframe`,
|
|
33
|
+
`memberships_dataframe`, `components_dataframe`.
|
|
34
|
+
- **scikit-learn** (`[sklearn]`): `Fuzzifier` transformer (crisp →
|
|
35
|
+
membership-degree features), `WangMendelRegressor`, `FuzzySystemRegressor`.
|
|
36
|
+
- **PyTorch** (`[torch]`): `FuzzyLayer`, a differentiable first-order TSK
|
|
37
|
+
`nn.Module` trainable by autograd and composable into a network.
|
|
38
|
+
- **SciPy** (`[scipy]`): `tune`, fitting a system's membership-function
|
|
39
|
+
parameters to data via `scipy.optimize.least_squares`.
|
|
40
|
+
- **Optuna** (`[optuna]`): `suggest_inference_spec`, `suggest_anfis`, and a
|
|
41
|
+
ready-made `tune_anfis` study.
|
|
42
|
+
- **Joblib / Dask** (`[parallel]`, `[dask]`): `parallel_predict`,
|
|
43
|
+
`multi_start_cmeans`, `dask_predict`.
|
|
44
|
+
- **LLM agents** (`[agents]`): `explain` (crisp output + fired rules) and
|
|
45
|
+
`inference_tool` (a LangChain `StructuredTool`).
|
|
46
|
+
- Tutorials section (investment-risk advisor, ANFIS, Fuzzy TOPSIS, clustering)
|
|
47
|
+
and an Integrations guide page; rendered plots and computed results embedded
|
|
48
|
+
throughout the docs.
|
|
49
|
+
|
|
9
50
|
## [0.2.0] - 2026-06-24
|
|
10
51
|
|
|
11
52
|
### Added
|
|
@@ -5,8 +5,8 @@ type: software
|
|
|
5
5
|
authors:
|
|
6
6
|
- family-names: Salmeron
|
|
7
7
|
given-names: Jose L.
|
|
8
|
-
version: 0.
|
|
9
|
-
date-released: 2026-06-
|
|
8
|
+
version: 0.4.0
|
|
9
|
+
date-released: 2026-06-28
|
|
10
10
|
doi: 10.5281/zenodo.20836712
|
|
11
11
|
license: MIT
|
|
12
12
|
repository-code: "https://github.com/fuzzytool/fuzzytool.github.io"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fuzzytool
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: A clean, extensible fuzzy-logic toolkit in pure Python + NumPy
|
|
5
5
|
Project-URL: Homepage, https://fuzzytool.github.io
|
|
6
6
|
Project-URL: Documentation, https://fuzzytool.github.io
|
|
@@ -18,10 +18,20 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
|
18
18
|
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
19
19
|
Requires-Python: >=3.9
|
|
20
20
|
Requires-Dist: numpy>=1.21
|
|
21
|
+
Provides-Extra: agents
|
|
22
|
+
Requires-Dist: langchain-core>=0.1; extra == 'agents'
|
|
23
|
+
Provides-Extra: dask
|
|
24
|
+
Requires-Dist: dask>=2022.0; extra == 'dask'
|
|
21
25
|
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: joblib>=1.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: langchain-core>=0.1; extra == 'dev'
|
|
28
|
+
Requires-Dist: optuna>=3.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pandas>=1.3; extra == 'dev'
|
|
22
30
|
Requires-Dist: pytest-cov; extra == 'dev'
|
|
23
31
|
Requires-Dist: pytest>=7; extra == 'dev'
|
|
24
32
|
Requires-Dist: ruff; extra == 'dev'
|
|
33
|
+
Requires-Dist: scikit-learn>=1.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: scipy>=1.7; extra == 'dev'
|
|
25
35
|
Provides-Extra: docs
|
|
26
36
|
Requires-Dist: mkdocs-material; extra == 'docs'
|
|
27
37
|
Requires-Dist: mkdocstrings[python]; extra == 'docs'
|
|
@@ -31,6 +41,20 @@ Requires-Dist: jupyter; extra == 'notebooks'
|
|
|
31
41
|
Requires-Dist: matplotlib>=3.4; extra == 'notebooks'
|
|
32
42
|
Requires-Dist: nbconvert; extra == 'notebooks'
|
|
33
43
|
Requires-Dist: nbformat; extra == 'notebooks'
|
|
44
|
+
Provides-Extra: optuna
|
|
45
|
+
Requires-Dist: optuna>=3.0; extra == 'optuna'
|
|
46
|
+
Provides-Extra: pandas
|
|
47
|
+
Requires-Dist: pandas>=1.3; extra == 'pandas'
|
|
48
|
+
Provides-Extra: parallel
|
|
49
|
+
Requires-Dist: joblib>=1.0; extra == 'parallel'
|
|
50
|
+
Provides-Extra: scipy
|
|
51
|
+
Requires-Dist: scipy>=1.7; extra == 'scipy'
|
|
52
|
+
Provides-Extra: sklearn
|
|
53
|
+
Requires-Dist: scikit-learn>=1.0; extra == 'sklearn'
|
|
54
|
+
Provides-Extra: torch
|
|
55
|
+
Requires-Dist: torch>=1.12; extra == 'torch'
|
|
56
|
+
Provides-Extra: turboswarm
|
|
57
|
+
Requires-Dist: turboswarm>=0.7; extra == 'turboswarm'
|
|
34
58
|
Provides-Extra: viz
|
|
35
59
|
Requires-Dist: matplotlib>=3.4; extra == 'viz'
|
|
36
60
|
Description-Content-Type: text/markdown
|
|
@@ -86,12 +110,29 @@ s-norm, `~` the complement.
|
|
|
86
110
|
|
|
87
111
|
| Phase | Content | Status |
|
|
88
112
|
|------|-----------|--------|
|
|
89
|
-
| 1 | Core: membership functions, t-/s-norms, `Variable`, operator rules, **Mamdani** + defuzzification,
|
|
113
|
+
| 1 | Core: membership functions, t-/s-norms, `Variable`, operator rules, **Mamdani** + defuzzification, fraud-alert example, tests | ✅ |
|
|
90
114
|
| 2 | **Takagi-Sugeno (TSK)** inference + `viz` (membership plots, control surface) | ✅ (TSK + viz) |
|
|
91
115
|
| 3 | **Type-2 / interval type-2** sets (footprint of uncertainty) + Karnik-Mendel type reduction | ✅ |
|
|
92
116
|
| 4 | **Fuzzy clustering**: fuzzy c-means, Gustafson-Kessel, possibilistic | ✅ |
|
|
93
117
|
| 5 | **ANFIS** (trainable TSK) + **F-transform** (direct/inverse) | ✅ |
|
|
94
118
|
| 6 | Notebooks, JOSS `paper.md`, Zenodo DOI, PyPI release | ✅ |
|
|
119
|
+
| 7 | **Ecosystem integrations**: pandas, scikit-learn, PyTorch, SciPy, turboswarm, Optuna, Joblib/Dask, LLM agents | ✅ |
|
|
120
|
+
|
|
121
|
+
### v0.4.0
|
|
122
|
+
|
|
123
|
+
- **turboswarm integration:** gradient-free, global tuning of a fuzzy system's
|
|
124
|
+
membership functions with Particle Swarm Optimization
|
|
125
|
+
(`integrations.turboswarm.tune`) — the metaheuristic sibling of the SciPy tuner.
|
|
126
|
+
|
|
127
|
+
### v0.3.0
|
|
128
|
+
|
|
129
|
+
- **Integrations** (`fuzzytool.integrations.*`, each behind its own extra):
|
|
130
|
+
**pandas** (DataFrame I/O), **scikit-learn** (`Fuzzifier`, regressors),
|
|
131
|
+
**PyTorch** (differentiable `FuzzyLayer`), **SciPy** (MF tuning), **Optuna**
|
|
132
|
+
(hyperparameter search), **Joblib/Dask** (parallel inference) and
|
|
133
|
+
**LLM agents** (explainable `inference_tool`).
|
|
134
|
+
- **Tutorials** and an **Integrations** guide page, with rendered plots and
|
|
135
|
+
computed outputs throughout the docs.
|
|
95
136
|
|
|
96
137
|
### v0.2.0
|
|
97
138
|
|
|
@@ -117,7 +158,7 @@ From source, for development:
|
|
|
117
158
|
python -m venv .venv && source .venv/bin/activate
|
|
118
159
|
pip install -e ".[dev,viz,docs]"
|
|
119
160
|
pytest -q
|
|
120
|
-
python examples/
|
|
161
|
+
python examples/fraud_alert.py
|
|
121
162
|
```
|
|
122
163
|
|
|
123
164
|
## Documentation
|
|
@@ -49,12 +49,29 @@ s-norm, `~` the complement.
|
|
|
49
49
|
|
|
50
50
|
| Phase | Content | Status |
|
|
51
51
|
|------|-----------|--------|
|
|
52
|
-
| 1 | Core: membership functions, t-/s-norms, `Variable`, operator rules, **Mamdani** + defuzzification,
|
|
52
|
+
| 1 | Core: membership functions, t-/s-norms, `Variable`, operator rules, **Mamdani** + defuzzification, fraud-alert example, tests | ✅ |
|
|
53
53
|
| 2 | **Takagi-Sugeno (TSK)** inference + `viz` (membership plots, control surface) | ✅ (TSK + viz) |
|
|
54
54
|
| 3 | **Type-2 / interval type-2** sets (footprint of uncertainty) + Karnik-Mendel type reduction | ✅ |
|
|
55
55
|
| 4 | **Fuzzy clustering**: fuzzy c-means, Gustafson-Kessel, possibilistic | ✅ |
|
|
56
56
|
| 5 | **ANFIS** (trainable TSK) + **F-transform** (direct/inverse) | ✅ |
|
|
57
57
|
| 6 | Notebooks, JOSS `paper.md`, Zenodo DOI, PyPI release | ✅ |
|
|
58
|
+
| 7 | **Ecosystem integrations**: pandas, scikit-learn, PyTorch, SciPy, turboswarm, Optuna, Joblib/Dask, LLM agents | ✅ |
|
|
59
|
+
|
|
60
|
+
### v0.4.0
|
|
61
|
+
|
|
62
|
+
- **turboswarm integration:** gradient-free, global tuning of a fuzzy system's
|
|
63
|
+
membership functions with Particle Swarm Optimization
|
|
64
|
+
(`integrations.turboswarm.tune`) — the metaheuristic sibling of the SciPy tuner.
|
|
65
|
+
|
|
66
|
+
### v0.3.0
|
|
67
|
+
|
|
68
|
+
- **Integrations** (`fuzzytool.integrations.*`, each behind its own extra):
|
|
69
|
+
**pandas** (DataFrame I/O), **scikit-learn** (`Fuzzifier`, regressors),
|
|
70
|
+
**PyTorch** (differentiable `FuzzyLayer`), **SciPy** (MF tuning), **Optuna**
|
|
71
|
+
(hyperparameter search), **Joblib/Dask** (parallel inference) and
|
|
72
|
+
**LLM agents** (explainable `inference_tool`).
|
|
73
|
+
- **Tutorials** and an **Integrations** guide page, with rendered plots and
|
|
74
|
+
computed outputs throughout the docs.
|
|
58
75
|
|
|
59
76
|
### v0.2.0
|
|
60
77
|
|
|
@@ -80,7 +97,7 @@ From source, for development:
|
|
|
80
97
|
python -m venv .venv && source .venv/bin/activate
|
|
81
98
|
pip install -e ".[dev,viz,docs]"
|
|
82
99
|
pytest -q
|
|
83
|
-
python examples/
|
|
100
|
+
python examples/fraud_alert.py
|
|
84
101
|
```
|
|
85
102
|
|
|
86
103
|
## Documentation
|
|
@@ -10,13 +10,13 @@ self-contained, testable increment.
|
|
|
10
10
|
- [x] T-norms / s-norms resolved by name; standard complement.
|
|
11
11
|
- [x] `Variable` + operator-based antecedent tree (`&`, `|`, `~`).
|
|
12
12
|
- [x] Mamdani inference + defuzzification (centroid, bisector, MOM/SOM/LOM).
|
|
13
|
-
- [x]
|
|
13
|
+
- [x] Fraud-alert example, test suite, packaging, docs, CI.
|
|
14
14
|
|
|
15
15
|
## ✅ Phase 2 — TSK + visualization
|
|
16
16
|
|
|
17
17
|
- [x] Takagi-Sugeno inference (zero/first-order + callable consequents).
|
|
18
18
|
- [x] `viz`: membership plots, 2-input control surface.
|
|
19
|
-
- [ ] Example notebooks (
|
|
19
|
+
- [ ] Example notebooks (fraud-alert, TSK).
|
|
20
20
|
|
|
21
21
|
## ✅ Phase 3 — Type-2 / interval type-2
|
|
22
22
|
|
|
@@ -51,11 +51,31 @@ self-contained, testable increment.
|
|
|
51
51
|
- [x] Vectorized batch inference (`Mamdani.predict` / `TSK.predict`);
|
|
52
52
|
JSON serialization (`save`/`load`); scikit-learn estimator interface on ANFIS.
|
|
53
53
|
|
|
54
|
+
## 🔌 Ecosystem integrations (`fuzzytool.integrations.*`)
|
|
55
|
+
|
|
56
|
+
Each pulls its dependency in only on import, behind its own extra.
|
|
57
|
+
|
|
58
|
+
- [x] **pandas** (`[pandas]`): `predict_df`, `rules_dataframe`,
|
|
59
|
+
`memberships_dataframe`, `components_dataframe`.
|
|
60
|
+
- [x] **scikit-learn** (`[sklearn]`): `Fuzzifier` transformer,
|
|
61
|
+
`WangMendelRegressor`, `FuzzySystemRegressor` (ANFIS already compatible).
|
|
62
|
+
- [x] **PyTorch** (`[torch]`): `FuzzyLayer`, a differentiable first-order TSK
|
|
63
|
+
`nn.Module` trainable by autograd and composable into a network.
|
|
64
|
+
- [x] **SciPy** (`[scipy]`): `tune` MF parameters to data via
|
|
65
|
+
`scipy.optimize.least_squares` (returns the `OptimizeResult`).
|
|
66
|
+
- [x] **turboswarm** (`[turboswarm]`): `tune` MF parameters with gradient-free
|
|
67
|
+
Particle Swarm Optimization (the sibling PSO library; returns `PsoResult`).
|
|
68
|
+
- [x] **Optuna** (`[optuna]`): `suggest_inference_spec`, `suggest_anfis` and a
|
|
69
|
+
ready-made `tune_anfis` study.
|
|
70
|
+
- [x] **Joblib / Dask** (`[parallel]`, `[dask]`): `parallel_predict`,
|
|
71
|
+
`multi_start_cmeans`, `dask_predict`.
|
|
72
|
+
- [x] **Agents (LangChain/LangGraph)** (`[agents]`): `explain` plus an
|
|
73
|
+
`inference_tool` LangChain tool that reports which rules fired.
|
|
74
|
+
|
|
54
75
|
## Ideas for later
|
|
55
76
|
|
|
56
77
|
- Fuzzy cognitive maps (+ grey FCM).
|
|
57
78
|
- General (non-interval) type-2; more defuzzifiers.
|
|
58
|
-
- FIS tuning via metaheuristics (e.g. PSO).
|
|
59
79
|
|
|
60
80
|
## ⏳ Phase 6 — Release (v0.1.0)
|
|
61
81
|
|
|
@@ -78,6 +78,34 @@ Generated from docstrings with `mkdocstrings`.
|
|
|
78
78
|
|
|
79
79
|
::: fuzzytool.viz
|
|
80
80
|
|
|
81
|
+
## Integrations — pandas
|
|
82
|
+
|
|
83
|
+
::: fuzzytool.integrations.pandas
|
|
84
|
+
|
|
85
|
+
## Integrations — scikit-learn
|
|
86
|
+
|
|
87
|
+
::: fuzzytool.integrations.sklearn
|
|
88
|
+
|
|
89
|
+
## Integrations — SciPy
|
|
90
|
+
|
|
91
|
+
::: fuzzytool.integrations.scipy
|
|
92
|
+
|
|
93
|
+
## Integrations — turboswarm (PSO)
|
|
94
|
+
|
|
95
|
+
::: fuzzytool.integrations.turboswarm
|
|
96
|
+
|
|
97
|
+
## Integrations — Optuna
|
|
98
|
+
|
|
99
|
+
::: fuzzytool.integrations.optuna
|
|
100
|
+
|
|
101
|
+
## Integrations — Joblib / Dask
|
|
102
|
+
|
|
103
|
+
::: fuzzytool.integrations.parallel
|
|
104
|
+
|
|
105
|
+
## Integrations — LLM agents
|
|
106
|
+
|
|
107
|
+
::: fuzzytool.integrations.agents
|
|
108
|
+
|
|
81
109
|
## Datasets
|
|
82
110
|
|
|
83
111
|
::: fuzzytool.datasets
|
|
@@ -41,8 +41,8 @@ sys.rule(score["good"] | score["excellent"], premium["low"])
|
|
|
41
41
|
The system is **callable**. Pass crisp inputs by variable name:
|
|
42
42
|
|
|
43
43
|
```python
|
|
44
|
-
sys(score=800, dti=10) # strong borrower -> low premium
|
|
45
|
-
sys(score=520, dti=42) # weak borrower
|
|
44
|
+
sys(score=800, dti=10) # strong borrower -> 2.45 pts (low premium)
|
|
45
|
+
sys(score=520, dti=42) # weak borrower -> 9.93 pts (high premium)
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
## 4. Visualize (optional)
|
|
@@ -55,3 +55,7 @@ viz.plot_variable(score)
|
|
|
55
55
|
viz.control_surface(sys, score, dti)
|
|
56
56
|
plt.show()
|
|
57
57
|
```
|
|
58
|
+
|
|
59
|
+

|
|
60
|
+
|
|
61
|
+

|
|
@@ -14,7 +14,7 @@ sys, *_ = datasets.credit_risk()
|
|
|
14
14
|
scores = np.array([520.0, 660.0, 800.0])
|
|
15
15
|
dtis = np.array([42.0, 30.0, 10.0])
|
|
16
16
|
|
|
17
|
-
sys.predict(score=scores, dti=dtis) # array
|
|
17
|
+
sys.predict(score=scores, dti=dtis) # -> array([10.16, 6. , 1.91]), one premium per sample
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
The result matches calling the system once per sample, but the firing, implication
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Worked example: fraud-alert score
|
|
2
|
+
|
|
3
|
+
A complete, runnable Mamdani system that scores card transactions for fraud. A
|
|
4
|
+
payment monitor turns how far a charge deviates from the customer's usual spend
|
|
5
|
+
(**amount anomaly**, in standard deviations, 0–8) and how many card swipes
|
|
6
|
+
happened in the last hour (**velocity**, 0–30) into a **fraud-risk** score
|
|
7
|
+
(0–100).
|
|
8
|
+
|
|
9
|
+
The full script lives in
|
|
10
|
+
[`examples/fraud_alert.py`](https://github.com/fuzzytool/fuzzytool/blob/main/examples/fraud_alert.py).
|
|
11
|
+
|
|
12
|
+
## 1. Define the linguistic variables
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
import fuzzytool as fz
|
|
16
|
+
|
|
17
|
+
amount_anomaly = fz.Variable("amount_anomaly", (0, 8))
|
|
18
|
+
amount_anomaly["normal"] = fz.trap(0, 0, 1, 2.5)
|
|
19
|
+
amount_anomaly["elevated"] = fz.tri(2, 3.5, 5)
|
|
20
|
+
amount_anomaly["extreme"] = fz.trap(4.5, 6, 8, 8)
|
|
21
|
+
|
|
22
|
+
velocity = fz.Variable("velocity", (0, 30))
|
|
23
|
+
velocity["low"] = fz.trap(0, 0, 3, 6)
|
|
24
|
+
velocity["moderate"] = fz.tri(4, 9, 14)
|
|
25
|
+
velocity["burst"] = fz.trap(12, 20, 30, 30)
|
|
26
|
+
|
|
27
|
+
fraud_risk = fz.Variable("fraud_risk", (0, 100))
|
|
28
|
+
fraud_risk["low"] = fz.tri(0, 12, 35)
|
|
29
|
+
fraud_risk["medium"] = fz.tri(30, 50, 70)
|
|
30
|
+
fraud_risk["high"] = fz.tri(65, 85, 100)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 2. Write the rule base
|
|
34
|
+
|
|
35
|
+
`&` is AND (t-norm), `|` is OR (s-norm), `~` is NOT (complement):
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
sys = fz.Mamdani(defuzz="centroid")
|
|
39
|
+
sys.rule(amount_anomaly["extreme"] | velocity["burst"], fraud_risk["high"])
|
|
40
|
+
sys.rule(amount_anomaly["elevated"] & velocity["moderate"], fraud_risk["medium"])
|
|
41
|
+
sys.rule(amount_anomaly["normal"] & velocity["low"], fraud_risk["low"])
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 3. Score transactions
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
sys(amount_anomaly=0.5, velocity=2) # routine charge -> ~16/100
|
|
48
|
+
sys(amount_anomaly=3.5, velocity=9) # borderline -> 50/100
|
|
49
|
+
sys(amount_anomaly=6.5, velocity=22) # likely fraud -> ~83/100
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 4. Visualize (optional)
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import matplotlib.pyplot as plt
|
|
56
|
+
from fuzzytool import viz
|
|
57
|
+
|
|
58
|
+
viz.plot_variable(amount_anomaly)
|
|
59
|
+
viz.control_surface(sys, amount_anomaly, velocity)
|
|
60
|
+
plt.show()
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+

|
|
64
|
+
|
|
65
|
+

|
|
@@ -7,7 +7,7 @@ uses a uniform triangular partition whose basis functions sum to 1 everywhere
|
|
|
7
7
|
|
|
8
8
|
- the **direct** transform reduces the data to `n_basis` components, each a
|
|
9
9
|
membership-weighted average of the samples under one basis function;
|
|
10
|
-
- the **inverse** transform reconstructs
|
|
10
|
+
- the **inverse** transform reconstructs $\hat{f}(x) = \sum_k F_k \, A_k(x)$.
|
|
11
11
|
|
|
12
12
|
Few components → a smoothing/denoising round trip; many components → a close
|
|
13
13
|
approximation.
|
|
@@ -39,8 +39,8 @@ matrix = [
|
|
|
39
39
|
]
|
|
40
40
|
weights = [tfn(0.4, 0.5, 0.6), tfn(0.3, 0.4, 0.5)]
|
|
41
41
|
res = fuzzy_topsis(matrix, weights, benefit=[True, True])
|
|
42
|
-
res.closeness # closeness coefficient per alternative
|
|
43
|
-
res.ranking # alternative indices, best first
|
|
42
|
+
res.closeness # -> array([0.369, 0.316]), closeness coefficient per alternative
|
|
43
|
+
res.ranking # -> [0, 1], alternative indices, best first
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
### Fuzzy AHP (Chang's extent analysis)
|
|
@@ -53,8 +53,8 @@ from fuzzytool.mcdm import fuzzy_ahp
|
|
|
53
53
|
|
|
54
54
|
one = tfn(1, 1, 1)
|
|
55
55
|
matrix = [
|
|
56
|
-
[one,
|
|
57
|
-
[tfn(1/
|
|
56
|
+
[one, tfn(1, 2, 3)],
|
|
57
|
+
[tfn(1/3, 1/2, 1), one],
|
|
58
58
|
]
|
|
59
|
-
fuzzy_ahp(matrix) #
|
|
59
|
+
fuzzy_ahp(matrix) # -> array([0.69, 0.31]), normalized crisp weights
|
|
60
60
|
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Rule learning
|
|
1
|
+
# Rule learning
|
|
2
2
|
|
|
3
3
|
## Learning a rule base from data (Wang-Mendel)
|
|
4
4
|
|
|
@@ -18,7 +18,7 @@ b = fz.Variable("b", (0, 10), terms=["lo", "mid", "hi"])
|
|
|
18
18
|
out = fz.Variable("out", (0, 10), terms=["lo", "mid", "hi"])
|
|
19
19
|
|
|
20
20
|
sys = fz.wang_mendel(X, y, [a, b], out) # a ready-to-use Mamdani system
|
|
21
|
-
sys(a=8, b=7)
|
|
21
|
+
sys(a=8, b=7) # -> 5.88 (learned system approximates the mean (a + b) / 2)
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
The input variables supply the partition; the learned system is a plain
|
|
@@ -39,7 +39,7 @@ x = fz.Variable("x", (0, 10), terms=["lo", "hi"])
|
|
|
39
39
|
sys = fz.Tsukamoto()
|
|
40
40
|
sys.rule(x["lo"], fz.ramp_down(0, 30)) # monotonic consequents only
|
|
41
41
|
sys.rule(x["hi"], fz.ramp_up(0, 30))
|
|
42
|
-
sys(x=7)
|
|
42
|
+
sys(x=7) # -> 21.0
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
Use [`ramp_up`][fuzzytool.membership.ramp_up],
|
|
@@ -20,7 +20,7 @@ sys.rule(x["small"], 0.0) # zero-order
|
|
|
20
20
|
sys.rule(x["large"], {"const": 1.0, "x": 1.0}) # first-order: 1 + x
|
|
21
21
|
sys.rule(x["small"], lambda x: x**2) # arbitrary callable
|
|
22
22
|
|
|
23
|
-
sys(x=10.0)
|
|
23
|
+
sys(x=10.0) # -> 11.0
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
TSK systems are typically faster and differentiable, which makes them the basis
|
|
@@ -49,7 +49,7 @@ premium["high"] = fz.it2_gauss_uncertain_mean(9.5, 10.5, 1.5)
|
|
|
49
49
|
sys = fz.IT2Mamdani()
|
|
50
50
|
sys.rule(score["good"], premium["low"])
|
|
51
51
|
sys.rule(score["poor"], premium["high"])
|
|
52
|
-
sys(score=780)
|
|
52
|
+
sys(score=780) # -> 2.29 (midpoint of the type-reduced interval)
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
A ready-made example is [`fuzzytool.datasets.credit_risk_it2`][fuzzytool.datasets].
|
|
@@ -62,6 +62,15 @@ reusable primitive ([`fuzzytool.type2.reduction`][fuzzytool.type2.reduction]):
|
|
|
62
62
|
`km_endpoint` finds one endpoint, `karnik_mendel` returns both, and
|
|
63
63
|
`centroid_it2` applies it to compute an IT2 set's centroid interval.
|
|
64
64
|
|
|
65
|
+
```python
|
|
66
|
+
import numpy as np
|
|
67
|
+
from fuzzytool.type2.reduction import centroid_it2
|
|
68
|
+
|
|
69
|
+
good = fz.it2_gauss_uncertain_mean(740, 780, 50)
|
|
70
|
+
universe = np.linspace(300, 850, 400)
|
|
71
|
+
centroid_it2(good, universe) # -> (738.05, 772.07), the [y_l, y_r] centroid interval
|
|
72
|
+
```
|
|
73
|
+
|
|
65
74
|
## Visualization
|
|
66
75
|
|
|
67
76
|
```python
|
|
@@ -71,3 +80,5 @@ from fuzzytool import viz
|
|
|
71
80
|
viz.plot_it2_variable(score) # draws each term's LMF/UMF with a shaded FOU
|
|
72
81
|
plt.show()
|
|
73
82
|
```
|
|
83
|
+
|
|
84
|
+

|
|
@@ -14,6 +14,8 @@ viz.plot_variable(premium)
|
|
|
14
14
|
plt.show()
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+

|
|
18
|
+
|
|
17
19
|
## Control surface
|
|
18
20
|
|
|
19
21
|
For a single-output system over two inputs:
|
|
@@ -25,3 +27,5 @@ sys, score, dti, premium = datasets.credit_risk()
|
|
|
25
27
|
viz.control_surface(sys, score, dti)
|
|
26
28
|
plt.show()
|
|
27
29
|
```
|
|
30
|
+
|
|
31
|
+

|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -33,4 +33,10 @@ sys(score=800, dti=10) # -> a crisp risk premium
|
|
|
33
33
|
|
|
34
34
|
- [Installation](installation.md)
|
|
35
35
|
- [Getting started](getting-started.md)
|
|
36
|
+
- [Tutorials](tutorials/risk-advisor.md) — end-to-end walkthroughs
|
|
36
37
|
- [The guide](guide/membership.md)
|
|
38
|
+
|
|
39
|
+
## Author
|
|
40
|
+
|
|
41
|
+
Created and maintained by **Jose L. Salmeron**. If you use fuzzytool in academic
|
|
42
|
+
work, please [cite it](citing.md).
|