How to get the mf value after defining a gaussian bell mf using skfuzzy?

175 views
Skip to first unread message

Steve Tan

unread,
Sep 26, 2018, 6:33:32 AM9/26/18
to scikit-fuzzy

Sorry for the super noob question here, but i'm trying to use the skfuzzy framework to create some gaussian bell membership function, as follows

import numpy as np
import skfuzzy as fuzz
from skfuzzy import control as ctrl

# New Antecedent/Consequent objects hold universe variables and membership
# functions
quality = ctrl.Antecedent(np.arange(0, 11, 1), 'quality')
service = ctrl.Antecedent(np.arange(0, 11, 1), 'service')
tip = ctrl.Consequent(np.arange(-30, 30, 1), 'tip')

# Auto-membership function population is possible with .automf(3, 5, or 7)
quality.automf(3)
service.automf(3)

# Custom membership functions can be built interactively with a familiar,
# Pythonic API
#tip['low'] = fuzz.trimf(tip.universe, [0, 0, 13])
#tip['medium'] = fuzz.trimf(tip.universe, [0, 13, 25])
#tip['high'] = fuzz.trimf(tip.universe, [13, 25, 25])
arr = []
sigma = 2.5
tip["EL"] = fuzz.gaussmf(tip.universe, -30, sigma)
tip["VL"] = fuzz.gaussmf(tip.universe, -20, sigma)
tip["L"] = fuzz.gaussmf(tip.universe, -10, sigma)
tip["M"] = fuzz.gaussmf(tip.universe, 0, sigma)
tip["H"] = fuzz.gaussmf(tip.universe, 10, sigma)
tip["VH"] = fuzz.gaussmf(tip.universe, 20, sigma)
tip["EH"] = fuzz.gaussmf(tip.universe, 30, sigma)

tip.view()

and after creating this, I would like to be able to get the value back based on each fuzzy segment that I've created as follows, tip["EH"].input = 5 and based on the bell curve created, I would like to get back the membership function value as per the plot. I've looked through the document but was'nt able to get it. Please help! Thanks

Reply all
Reply to author
Forward
0 new messages