How do i use Crisp variables in skfuzzy python library?

249 views Asked by At

I m biulding a model using skfuzzy, python library, but in my problem i have crisp and fuzzy variables, how can i include this crisp variables in my calculation? for exemple: i have a age variable, this is fuzzy, but i have a smoke variable, that is crisp because the answer is "yes" or "no" only, how can i add this in the model? I have tried to biuld a variable, but i did not have sucess cause i did not find a way to do this in skfuzzy.

import skfuzzy as fuzz
from skfuzzy import control as ctrl

idade = ctrl.Antecedent(np.arange(0, 101, 1), 'idade')
idade['muito jovem'] = fuzz.trapmf(idade.universe, [0, 0, 13, 20])
idade['jovem'] = fuzz.trapmf(idade.universe, [15, 22, 28, 35])
idade['moderado'] = fuzz.trapmf(idade.universe, [30, 37, 48, 55])
idade['avançado'] = fuzz.trapmf(idade.universe, [50, 57, 73, 80])
idade['muito avançado'] = fuzz.trapmf(idade.universe, [75, 82, 97, 100])
#idade.view()```
1

There are 1 answers

0
Julius Sechang Mboli On

I suggest that you convert your smoke variable which is crisp value to fuzzy by declaring a universe say 1 to 10 then split the variable into two with 1 to 5 for a Yes and 6 to 10 for a No. The following is an example:

age = ctrl.Antecedent(np.arange(0, 11, 1), 'age')
age['Yes'] = fuzz.trapmf(age.universe, [1, 3, 5])
age['No'] = fuzz.trapmf(age.universe, [3, 6, 10])

Your step value can be 5 or 1 and this would allow you to use it in fuzzy control system.