Tutorial 3 - Standard membership functions

This tutorial uses the fuzzy inference system developed in Tutorial 1.

[1]:
import os
import warnings

os.chdir('/workspaces/fuzzy-expert')
warnings.filterwarnings("ignore")

Specification of the fuzzy variables with standard membership functions

In the following code, fuzzy sets are specified using standard membership functions, which are described in the function reference section.

Fuzzy sets in variables score and ratio are specified using the smf and zmf functions. Fuzzy sets for variables credit and decision are specified using the trapmf function.

[2]:
import matplotlib.pyplot as plt
import numpy as np

from fuzzy_expert.variable import FuzzyVariable

variables = {
    "score": FuzzyVariable(
        universe_range=(150, 200),
        terms={
            "High": ('smf', 175, 190),
            "Low": ('zmf', 155, 175),
        },
    ),
    "ratio": FuzzyVariable(
        universe_range=(0.1, 1),
        terms={
            "Goodr": ('zmf', 0.3, 0.42),
            "Badr": ('smf', 0.44, 0.7),
        },
    ),
    #
    "credit": FuzzyVariable(
        universe_range=(0, 10),
        terms={
            "Goodc": ('trapmf', 0, 0, 2, 5),
            "Badc":  ('trapmf', 5, 8, 10, 10),
        },
    ),
    #
    "decision": FuzzyVariable(
        universe_range=(0, 10),
        terms={
            "Approve": ('trapmf', 5, 8, 10, 10),
            "Reject": ('trapmf', 0, 0, 2, 5),
        },
    ),
}
[3]:
variables['score'].plot()
../_images/tutorials_tutorial-3_6_0.svg
[4]:
variables['ratio'].plot()
../_images/tutorials_tutorial-3_7_0.svg
[5]:
variables['credit'].plot()
../_images/tutorials_tutorial-3_8_0.svg
[6]:
variables['decision'].plot()
../_images/tutorials_tutorial-3_9_0.svg