Skip to main content

A comprehensive Python library for fuzzy systems: inference (Mamdani, Sugeno), learning (ANFIS, Wang-Mendel, MandaniLearning), and dynamics (p-fuzzy, fuzzy ODEs)

Project description

pyfuzzy-toolbox

PyPI version Python Versions License: MIT Downloads Documentation

A comprehensive Python library for Fuzzy Systems with focus on education and professional applications. Includes inference, learning, fuzzy differential equations, and p-fuzzy systems.

๐Ÿ“š Documentation

Read the full documentation โ†’

  • Getting Started: Installation and quick tutorials
  • User Guides: In-depth guides for each module
  • API Reference: Complete method documentation
  • Examples: 18+ interactive Colab notebooks

๐Ÿ“ฆ Installation

Basic Installation (Library only)

pip install pyfuzzy-toolbox

Full Installation (with Web Interface)

For the complete experience including the interactive web interface:

macOS/Linux (Zsh/Bash):

pip install 'pyfuzzy-toolbox[ui]'

Windows (PowerShell/CMD):

pip install pyfuzzy-toolbox[ui]

Note: Package name is pyfuzzy-toolbox, import as fuzzy_systems:

import fuzzy_systems as fs

๐Ÿ–ฅ๏ธ Web Interface (NEW!)

Launch the interactive web interface with a single command:

pyfuzzy interface

This opens a modern Streamlit-based interface featuring:

  • ๐ŸŽฏ ANFIS: Complete workflow (data โ†’ training โ†’ evaluation โ†’ prediction)
  • ๐Ÿ“Š Interactive visualizations: Membership functions, decision surfaces, training curves
  • ๐Ÿ”ฎ Real-time predictions: Manual input or batch CSV upload
  • ๐Ÿ“ˆ Model analysis: Rules visualization, feature importance, sensitivity analysis
  • ๐Ÿ’พ Export capabilities: Models, predictions, and results

CLI Commands

# Launch web interface (browser opens automatically)
pyfuzzy interface

# Custom port and dark theme
pyfuzzy interface --port 8080 --dark-theme

# Headless mode (no browser)
pyfuzzy interface --no-browser

# Show version
pyfuzzy version

# Help
pyfuzzy --help

Programmatic API

Launch the interface from Python code or Jupyter notebooks:

from fuzzy_systems import launch_interface

# Simple launch
launch_interface()

# Custom configuration
launch_interface(
    port=8080,
    theme='dark',
    open_browser=True
)

๐Ÿงฉ Core Modules

fuzzy_systems.core

Fundamental fuzzy logic components

  • Membership functions: triangular, trapezoidal, gaussian, sigmoid, generalized_bell
  • Classes: FuzzySet, LinguisticVariable
  • Operators: fuzzy_and_min, fuzzy_or_max, fuzzy_not

fuzzy_systems.inference

Fuzzy inference systems

  • MamdaniSystem: Classic fuzzy inference with defuzzification (COG, MOM, etc.)
  • SugenoSystem: TSK systems with functional outputs (order 0 and 1)

fuzzy_systems.learning

Learning and optimization

  • ANFIS: Adaptive Neuro-Fuzzy Inference System
  • WangMendel: Automatic rule generation from data
  • MamdaniLearning: Gradient descent and metaheuristics (PSO, DE, GA)

fuzzy_systems.dynamics

Fuzzy dynamic systems

  • FuzzyODE: Solve ODEs with fuzzy uncertainty (ฮฑ-level method)
  • PFuzzySystem: Discrete and continuous p-fuzzy systems

๐Ÿ““ Interactive Notebooks

Explore hands-on examples organized by topic:

Topic Notebooks Description
01_fundamentals 2 notebooks Membership functions, fuzzy sets, operators, fuzzification
02_inference 4 notebooks Mamdani and Sugeno systems
03_learning 7 notebooks Wang-Mendel, ANFIS, optimization
04_dynamics 5 notebooks Fuzzy ODEs, p-fuzzy systems

All notebooks can be opened directly in Google Colab!

๐Ÿ“– Quick Start Guides

Comprehensive guides for each module with theory, examples, and best practices:

๐ŸŽ›๏ธ Inference Systems

Build fuzzy control systems and decision-making tools.

Mamdani System

Linguistic fuzzy inference with interpretable rules.

  • โœ… Intuitive rule creation
  • โœ… Multiple defuzzification methods
  • โœ… Visualization tools
  • ๐Ÿ““ Tipping Example

Sugeno System

Efficient inference with mathematical consequents.

  • โœ… Order 0 (constant) or Order 1 (linear)
  • โœ… Fast computation
  • โœ… Ideal for optimization
  • ๐Ÿ““ Zero-Order Example

๐Ÿง  Learning & Optimization

Automatic rule generation and parameter tuning from data.

Wang-Mendel

Single-pass rule extraction.

  • โœ… Fast learning
  • โœ… Auto task detection
  • โœ… Interpretable rules
  • ๐Ÿ““ Nonlinear Example

ANFIS

Neuro-fuzzy hybrid learning.

  • โœ… Gradient descent
  • โœ… Metaheuristics (PSO/DE/GA)
  • โœ… High accuracy
  • ๐Ÿ““ Classification Example

Mamdani Learning

Optimize existing systems.

  • โœ… SA, GA, PSO, DE
  • โœ… Preserve interpretability
  • โœ… Fine-tune consequents
  • ๐Ÿ““ Optimization Example

๐ŸŒŠ Dynamic Systems

Model temporal evolution with fuzzy uncertainty.

p-Fuzzy Discrete

Discrete-time dynamics.

  • โœ… x_{n+1} = x_n + f(x_n)
  • โœ… Absolute/relative modes
  • โœ… Population models
  • ๐Ÿ““ Predator-Prey Example

p-Fuzzy Continuous

Continuous-time dynamics.

  • โœ… dx/dt = f(x)
  • โœ… Euler or RK4
  • โœ… Adaptive stepping
  • ๐Ÿ““ Continuous Example

Fuzzy ODE

ODEs with fuzzy uncertainty.

  • โœ… ฮฑ-level method
  • โœ… Fuzzy parameters/ICs
  • โœ… Monte Carlo option
  • ๐Ÿ““ Logistic Example

๐Ÿ“š View All Guides


โšก Quick Example

import fuzzy_systems as fs

# Create Mamdani system
system = fs.MamdaniSystem()
system.add_input('temperature', (0, 40))
system.add_output('fan_speed', (0, 100))

# Add terms
system.add_term('temperature', 'cold', 'triangular', (0, 0, 20))
system.add_term('temperature', 'hot', 'triangular', (20, 40, 40))
system.add_term('fan_speed', 'slow', 'triangular', (0, 0, 50))
system.add_term('fan_speed', 'fast', 'triangular', (50, 100, 100))

# Add rules
system.add_rules([('cold', 'slow'), ('hot', 'fast')])

# Evaluate
result = system.evaluate(temperature=25)
print(f"Fan speed: {result['fan_speed']:.1f}%")

๐Ÿ”— Links

๐Ÿ“ Citation

@software{pyfuzzy_toolbox,
  title = {pyfuzzy-toolbox: A Comprehensive Python Library for Fuzzy Systems},
  author = {Cecconello, Moiseis},
  year = {2025},
  url = {https://github.com/1moi6/pyfuzzy-toolbox},
  note = {Includes inference, learning, fuzzy differential equations, and p-fuzzy systems}
}

๐Ÿ“„ License

MIT License - see LICENSE for details.

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

pyfuzzy_toolbox-1.1.8.tar.gz (6.7 MB view details)

Uploaded Source

Built Distribution

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

pyfuzzy_toolbox-1.1.8-py3-none-any.whl (314.8 kB view details)

Uploaded Python 3

File details

Details for the file pyfuzzy_toolbox-1.1.8.tar.gz.

File metadata

  • Download URL: pyfuzzy_toolbox-1.1.8.tar.gz
  • Upload date:
  • Size: 6.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for pyfuzzy_toolbox-1.1.8.tar.gz
Algorithm Hash digest
SHA256 d738c31d3dc5733a9c363e2eb09668c67328210ee2bf441e6b6bad801e931fa6
MD5 51a8fe17a784121fea1823d94571812a
BLAKE2b-256 8d3384bc3d718ce4f10fb193db34a2ed3f3a8dfdede2ed05eb093d18f5a7dbc8

See more details on using hashes here.

File details

Details for the file pyfuzzy_toolbox-1.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for pyfuzzy_toolbox-1.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 c637f094f8947d58dbab35f4838984897c1f80ab488ad002b1c7f0c2996fe128
MD5 9a9b782e889534f9dff31d4867a2c933
BLAKE2b-256 fff0605a7d21f0c34c154dff9f1776d3dbda981164902657a1ead72a5aee5ee6

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