scikit-fuzzy
is an fuzzy logic Python package that works with
numpy
arrays. The package is imported as skfuzzy
:
>>> import skfuzzy
though the recommended import statement uses an alias:
>>> import skfuzzy as fuzz
Most functions of skfuzzy
are brought into the base package namespace.
You can introspect the functions available in fuzz
when using IPython by:
[1] import skfuzzy as fuzz
[2] fuzz.
and pressing the Tab key.
A list of submodules and functions is found on the API reference webpage.
Within scikit-fuzzy
, universe variables and fuzzy membership functions are
represented by numpy
arrays. Generation of membership functions is
as simple as:
>>> import numpy as np
>>> import skfuzzy as fuzz
>>> x = np.arange(11)
>>> mfx = fuzz.trimf(x, [0, 5, 10])
>>> x
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
>>> mfx
array([ 0. , 0.2, 0.4, 0.6, 0.8, 1. , 0.8, 0.6, 0.4, 0.2, 0. ])
While most functions are available in the base namespace, the package is factored with a logical grouping of functions in submodules. If the base namespace appears overwhelming, we recommend exploring them individually. These include
fuzz.membership
fuzz.defuzzify
fuzz.fuzzymath
scikit-fuzzy
, containing the majority of the most common
fuzzy logic operations.fuzz.intervals
fuzz.image
fuzz.cluster
fuzz.filters