Registry / ai-ml / scikit-fuzzy

scikit-fuzzy

JSON →
library0.5.0pypypiunverified

scikit-fuzzy is a fuzzy logic toolkit for SciPy, providing a robust collection of independently developed and implemented fuzzy logic algorithms. It aims to offer a Pythonic alternative to closed-source fuzzy logic software. The library is currently at version 0.5.0 and receives periodic updates, indicating active maintenance and development.

pip install -U scikit-fuzzy
INSTALL
IMPORT
SIG · SCIKIT-FUZZY
S
scikit-fuzzy
ai-mlpythonv0.5.0
Install
1.6s avg
Import
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 20MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

skfuzzy
import skfuzzy as fuzz
import skfuzzy
The common and recommended practice is to import `skfuzzy` with the alias `fuzz` for brevity and consistency with examples.
control
from skfuzzy import control as ctrl
import skfuzzy.control
Classes for building fuzzy control systems (e.g., `Antecedent`, `Consequent`, `ControlSystem`) reside in the `control` submodule and are typically aliased as `ctrl`.
numpy
import numpy as np
Often used alongside scikit-fuzzy for defining universe variables and membership functions.
pyplot
from matplotlib import pyplot as plt
Frequently used for visualizing fuzzy sets, membership functions, and control surfaces.

This quickstart demonstrates how to define a universe of discourse using NumPy and then create triangular fuzzy membership functions using `fuzz.trimf`. It then plots these membership functions using Matplotlib to visualize the fuzzy sets. This is a fundamental step in building any fuzzy logic system with scikit-fuzzy.

import numpy as np import skfuzzy as fuzz import matplotlib.pyplot as plt # Generate universe variables x = np.arange(0, 11, 1) # Points from 0 to 10 # Generate fuzzy membership functions low = fuzz.trimf(x, [0, 0, 5]) medium = fuzz.trimf(x, [0, 5, 10]) high = fuzz.trimf(x, [5, 10, 10]) # Visualize these universes and membership functions plt.figure() plt.plot(x, low, 'b', linewidth=1.5, label='Low') plt.plot(x, medium, 'g', linewidth=1.5, label='Medium') plt.plot(x, high, 'r', linewidth=1.5, label='High') plt.title('Fuzzy Membership Functions') plt.ylabel('Membership value') plt.xlabel('Universe Variable') plt.legend() plt.grid(True) plt.show()
Debug
Known issues
breakingscikit-fuzzy adheres to the IEEE standard for rounding, which can lead to slight numerical differences compared to MATLAB's rounding behavior (e.g., 2.5 rounds to 2, 3.5 rounds to 4). If re-implementing algorithms from MATLAB, expect minor inconsistencies due to this.
fix
Be aware of the IEEE rounding standard when comparing results with MATLAB. This is intentional and not considered a bug.
affects: All versions
breakingThe fuzzy control system API (within `skfuzzy.control`) underwent significant changes and improvements in earlier major releases (e.g., 0.3.0 introduced a new API). Older implementations of fuzzy control systems might require updates to use the new `Antecedent`, `Consequent`, `ControlSystem`, and `ControlSystemSimulation` classes.
fix
Consult the `skfuzzy.control` documentation and examples for the current API. Update control system definitions to use `ctrl.Antecedent`, `ctrl.Consequent`, etc., and leverage `ControlSystemSimulation` for computations.
affects: < 0.3.0
gotchaClasses and functions related to fuzzy control systems (e.g., `Antecedent`, `Consequent`, `ControlSystem`) are *not* directly available in the main `skfuzzy` namespace. They must be explicitly imported from the `skfuzzy.control` submodule.
fix
Always use `from skfuzzy import control as ctrl` to access fuzzy control system components, then reference them as `ctrl.Antecedent`, `ctrl.Consequent`, etc.
affects: All versions
gotchaThere have been reports of compatibility issues with Python 3.12, often surfacing through underlying dependency conflicts. While `scikit-fuzzy` aims for broad Python support, specific environment configurations with Python 3.12 might encounter problems.
fix
If encountering issues with Python 3.12, consider using Python 3.11 or earlier. Monitor `scikit-fuzzy`'s GitHub for updates on Python 3.12 compatibility. Ensure all dependencies are up-to-date and compatible with your Python version.
affects: 0.5.0 (with Python 3.12)
Upgrade
Version history
0.5.0latest on PyPI · released Aug 22, 2024
Audit
Dependencies
MatplotlibrequiredRequired for plotting and visualization of fuzzy sets and control system results.
NumPyrequiredFundamental for numerical operations and array manipulation, which underpins all fuzzy set representations.
SciPyrequiredProvides core scientific computing functions that scikit-fuzzy builds upon.
NetworkXrequiredUsed internally for certain graph-based operations, especially within fuzzy control systems.
Agent activity
47 hits · last 30 days
node
42
OpenAI (training)
1
Resources