Daniel notes
you@here:~/articles/anfis-toolbox$ cat index.md

#anfis #fuzzy #python

ANFIS Toolbox

ANFIS Toolbox is a Python library for creating, training and deploying Adaptive Neuro-Fuzzy Inference Systems. It implements the classic Takagi-Sugeno-Kang ANFIS on top of NumPy, behind an interface that will look familiar to anyone who has used scikit-learn.

pip install anfis-toolbox
import micropip
await micropip.install("anfis-toolbox")  # only needed here, in the browser

import numpy as np
from anfis_toolbox import ANFISRegressor

rng = np.random.default_rng(0)
X = rng.uniform(-2, 2, (200, 2))
y = X[:, 0] ** 2 + X[:, 1] ** 2

model = ANFISRegressor()
model.fit(X, y)
print("R2:", round(model.score(X, y), 4))

Tip

Press [run] on the block above. The library is pure Python on top of NumPy, so it installs and trains inside this page. The first run takes a few seconds while Python itself is downloaded.

What is in it

  • Two estimators, ANFISRegressor and ANFISClassifier, with fit, predict, score and an evaluate that reports the usual metrics.
  • The four-layer architecture: membership, rules, normalization and consequent. How ANFIS works walks through it.
  • Thirteen membership functions, from Gaussian and bell shapes to triangular, trapezoidal, sigmoidal, S, Z and Pi shapes.
  • Trainers kept apart from the model: hybrid (gradient descent plus least squares), SGD, Adam, RMSProp and particle swarm optimization.
  • Initialization strategies for the fuzzy sets: fuzzy c-means, grid and random.

Articles

What Where
Documentation https://dcruzf.github.io/anfis-toolbox/
Source https://github.com/dcruzf/anfis-toolbox
Package https://pypi.org/project/anfis-toolbox/
Cite it doi:10.5281/zenodo.17437178
License MIT