scikit-fuzzy

0.5.0 · active · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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()

view raw JSON →