Skip to main content

A Python toolbox for building, training, and evaluating Adaptive Neuro-Fuzzy Inference System (ANFIS) models.

Project description

CI Python 3.10+ Docs coverage License: MIT security: bandit uv Ruff Hatch Mypy

A batteries-included Adaptive Neuro-Fuzzy Inference System (ANFIS) toolkit built in pure Python. It exposes high-level regression and classification APIs, modern trainers, and a rich catalog of membership functions.

🚀 Overview

  • Takagi–Sugeno–Kang (TSK) ANFIS with the classic four-layer architecture (Membership → Rules → Normalization → Consequent).
  • Regressor and classifier facades with a familiar scikit-learn style (fit, predict, score).
  • Trainers (Hybrid, SGD, Adam, RMSProp, PSO) decoupled from the model for easy experimentation.
  • 10+ membership function families. The primary public interfaces are ANFISRegressor and ANFISClassifier.
  • Thorough test coverage (100%+).

📦 Installation

Install from PyPI:

pip install anfis-toolbox

🧠 Quick start

Regression

import numpy as np
from anfis_toolbox import ANFISRegressor

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

model = ANFISRegressor()
model.fit(X, y)
metrics = model.evaluate(X, y)

Classification

import numpy as np
from anfis_toolbox import ANFISClassifier

X = np.r_[np.random.normal(-1, .3, (50, 2)), np.random.normal(1, .3, (50, 2))]
y = np.r_[np.zeros(50, int), np.ones(50, int)]

model = ANFISClassifier()
model.fit(X, y)
metrics = model.evaluate(X, y)

🧩 Membership functions at a glance

  • Gaussian (GaussianMF) - Smooth bell curves
  • Gaussian2 (Gaussian2MF) - Two-sided Gaussian with flat region
  • Triangular (TriangularMF) - Simple triangular shapes
  • Trapezoidal (TrapezoidalMF) - Plateau regions
  • Bell-shaped (BellMF) - Generalized bell curves
  • Sigmoidal (SigmoidalMF) - S-shaped transitions
  • Diff-Sigmoidal (DiffSigmoidalMF) - Difference of two sigmoids
  • Prod-Sigmoidal (ProdSigmoidalMF) - Product of two sigmoids
  • S-shaped (SShapedMF) - Smooth S-curve transitions
  • Linear S-shaped (LinSShapedMF) - Piecewise linear S-curve
  • Z-shaped (ZShapedMF) - Smooth Z-curve transitions
  • Linear Z-shaped (LinZShapedMF) - Piecewise linear Z-curve
  • Pi-shaped (PiMF) - Bell with flat top

🛠️ Training options

  • SGD (Stochastic Gradient Descent) – Classic gradient-based optimization with incremental updates
  • Adam – Adaptive learning rates with momentum for faster convergence
  • RMSProp – Scales learning rates by recent gradient magnitudes for stable training
  • PSO (Particle Swarm Optimization) – Population-based global search strategy
  • Hybrid SGD + OLS – Combines gradient descent with least-squares parameter refinement
  • Hybrid Adam + OLS – Integrates adaptive optimization with analytical least-squares adjustment

📚 Documentation

  • Comprehensive guides, API reference, and examples: docs/ (built with MkDocs).

🧪 Testing & quality

Run the full suite (pytest + coverage):

make test

Additional targets:

  • make lint — Run Ruff linting
  • make docs — Build the MkDocs site locally
  • make help — Show all available targets with their help messages

This project is tested on Python 3.10 | 3.11 | 3.12 | 3.13 | 3.14 across Linux, Windows and macOS.

🤝 Contributing

Issues and pull requests are welcome! Please open a discussion if you’d like to propose larger changes. See the docs/guide section for architecture notes and examples.

📄 License

Distributed under the MIT License. See LICENSE for details.

📚 References

  1. Jang, J. S. (1993). ANFIS: adaptive-network-based fuzzy inference system. IEEE transactions on systems, man, and cybernetics, 23(3), 665-685. https://doi.org/10.1109/21.256541

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

anfis_toolbox-0.1.0rc0.tar.gz (137.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anfis_toolbox-0.1.0rc0-py3-none-any.whl (88.0 kB view details)

Uploaded Python 3

File details

Details for the file anfis_toolbox-0.1.0rc0.tar.gz.

File metadata

  • Download URL: anfis_toolbox-0.1.0rc0.tar.gz
  • Upload date:
  • Size: 137.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for anfis_toolbox-0.1.0rc0.tar.gz
Algorithm Hash digest
SHA256 d0f331832cd34c0a9131d7986071a92a3e476f58f6cb83c2a4c2d32f32a7ad0e
MD5 d324df73f1d7d2e860d3273f15648b85
BLAKE2b-256 b2afa1d730ce5c311ec3d60191d1762f587621cb10baec049e49500b7f8d5518

See more details on using hashes here.

File details

Details for the file anfis_toolbox-0.1.0rc0-py3-none-any.whl.

File metadata

File hashes

Hashes for anfis_toolbox-0.1.0rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 930b28a39a6fa925778b938b1f4f69a67a7c909670b70267e204367d67415434
MD5 ff0c087cf856e2d5d0169aee6fb4edbd
BLAKE2b-256 fce5519a997ea21b75471251d52e1463918d5c9618b8a7a9170841bafefbf53f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page