Skip to content

Command Line Interface (CLI)

pyfuzzy-toolbox includes a modern command-line interface for quick access to the web interface and other utilities.

Installation

To use the CLI, install pyfuzzy-toolbox with the [ui] extras:

pip install 'pyfuzzy-toolbox[ui]'
pip install pyfuzzy-toolbox[ui]

Why the quotes?

On macOS/Linux (Zsh/Bash), the square brackets [] need to be quoted to prevent shell expansion.

Quick Start

Launch the web interface with a single command:

pyfuzzy interface

This will:

  1. ✅ Start the Streamlit server
  2. ✅ Automatically open your browser
  3. ✅ Display the interactive ANFIS interface

Press Ctrl+C to stop the server.

Available Commands

interface - Launch Web Interface

Open the interactive web application.

pyfuzzy interface [OPTIONS]

Options:

Option Type Default Description
--port int 8501 Port number for the web server
--host string localhost Host address to bind
--dark-theme flag False Use dark theme
--browser / --no-browser flag True Auto-open browser
--help flag - Show help message

Examples:

# Default: localhost:8501, auto-open browser
pyfuzzy interface

# Custom port
pyfuzzy interface --port 8080

# Dark theme without browser
pyfuzzy interface --dark-theme --no-browser

# Custom host (for remote access)
pyfuzzy interface --host 0.0.0.0 --port 8080

Port Auto-Detection

If the specified port is already in use, pyfuzzy will automatically find the next available port.

version - Show Version Info

Display package version and system information.

pyfuzzy version

Output:

╭── Package Info ──╮
│ pyfuzzy-toolbox  │
│ Version: 1.1.3   │
│ Python: 3.11.9   │
│ Platform: darwin │
╰──────────────────╯

demo - Run Demos

Run demonstration examples (coming soon).

pyfuzzy demo [NAME]

Global Options

pyfuzzy --help              # Show help for all commands
pyfuzzy --install-completion  # Install shell completion
pyfuzzy --show-completion     # Show completion script

Programmatic API

You can also launch the interface from Python code:

from fuzzy_systems import launch_interface

# Simple launch
launch_interface()

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

Parameters:

Parameter Type Default Description
port int None Port number (auto-detects if None)
host str 'localhost' Host address
open_browser bool True Auto-open browser
theme str None 'light' or 'dark'
auto_find_port bool True Find free port if occupied

Use Cases:

Jupyter Notebooks

Launch the interface alongside your notebook:

import fuzzy_systems as fs

# Train your model
model = fs.learning.ANFIS(n_inputs=2, n_mfs=3)
model.fit(X_train, y_train)

# Open interface for interactive analysis
fs.launch_interface()

Scripts and Automation

import fuzzy_systems as fs

# Run in headless mode for server deployment
fs.launch_interface(
    host='0.0.0.0',
    port=8501,
    open_browser=False
)

Alternative: Python Module

If the pyfuzzy command is not available, use the Python module directly:

python -m fuzzy_systems.cli interface
python -m fuzzy_systems.cli version
python -m fuzzy_systems.cli --help

Troubleshooting

Command not found

Problem:

pyfuzzy interface
zsh: command not found: pyfuzzy

Solutions:

  1. Verify installation:

    pip show pyfuzzy-toolbox
    

  2. Use Python module:

    python -m fuzzy_systems.cli interface
    

  3. Check PATH:

    which python
    echo $PATH
    

  4. Reinstall:

    pip uninstall pyfuzzy-toolbox -y
    pip install 'pyfuzzy-toolbox[ui]'
    

Port already in use

Problem:

⚠️ Port 8501 is occupied. Using port 8502 instead.

This is normal! pyfuzzy automatically finds a free port. If you want a specific port:

pyfuzzy interface --port 9000

Browser doesn't open

Problem: Server starts but browser doesn't open automatically.

Solutions:

  1. Manual access: Open your browser and go to http://localhost:8501

  2. Check headless mode:

    pyfuzzy interface --browser  # Ensure browser mode is on
    

  3. Try different browser: Set as default and retry

Streamlit not found

Problem:

ModuleNotFoundError: No module named 'streamlit'

Solution: Install with UI extras:

pip install 'pyfuzzy-toolbox[ui]'

Web Interface Features

Once the interface is running, you'll have access to:

🎯 ANFIS Module

Complete workflow for Adaptive Neuro-Fuzzy Inference Systems:

  1. Dataset Tab
  2. Load CSV files
  3. Use classic datasets (Iris, Wine, Breast Cancer, Diabetes)
  4. Generate synthetic data
  5. Train/Validation/Test split
  6. Data normalization

  7. Training Tab

  8. Configure architecture (MFs, type)
  9. Hybrid Learning (backpropagation + LSE)
  10. Metaheuristic optimization (PSO, DE, GA)
  11. Regularization (L1/L2)
  12. Real-time training curves

  13. Metrics Tab

  14. Regression: RMSE, MAE, R², MAPE
  15. Classification: Accuracy, Precision, Recall, F1
  16. Scatter plots (Predicted vs Actual)
  17. Residual analysis
  18. Confusion matrix

  19. Prediction Tab

  20. Manual input with custom values
  21. Batch prediction (CSV upload)
  22. Export predictions (Train/Val/Test)

  23. Model Analysis Tab

  24. Architecture overview
  25. Membership functions visualization
  26. Fuzzy rules (3 views: Table, Visual Matrix, Activation)
  27. 3D decision surface (2-input models)
  28. Feature importance (3 methods)

  29. What is ANFIS? Tab

  30. Theory and explanation
  31. Architecture details
  32. Use cases

📊 Other Modules (Coming Soon)

  • Mamdani Systems
  • Sugeno Systems
  • Wang-Mendel Learning
  • Fuzzy ODEs
  • p-Fuzzy Systems

Next Steps

Feedback

Having issues or suggestions? Please open an issue on GitHub!