Нечеткая система в Python ОШИБКА
У меня есть нечеткая система в Python с 4 треугольными входами MF, с юниверсом, определенным между 0 и 1 (плохое, среднее и хорошее). В качестве вывода у меня есть треугольная MF со вселенной, определенной также между 0 и 1, но разделенной на 7 категорий. Кроме того, у меня есть 81 правила, которые рассматривают все возможности, возникающие из этих MF. Но при запуске кода я всегда сталкиваюсь с этой ошибкой:
C:\Users\Rondy\PycharmProjects\confiabilidade\venv\Scripts\python.exe C:/Users/Rondy/PycharmProjects/confiabilidade/Fuzzy.py
Traceback (most recent call last):
File "C:/Users/Rondy/PycharmProjects/confiabilidade/Fuzzy.py", line 184, in <module>
tipping.input['conf'] = 0.2
ile "C:\Users\Rondy\PycharmProjects\confiabilidade\venv\lib\site-packages\skfuzzy\control\controlsystem.py", line 143, in __setitem__
raise ValueError("Unexpected input: " + key)
ValueError: Unexpected input: conf
Что это может быть?
Код:
import matplotlib.pyplot as plt
import numpy as np
import skfuzzy as fuzz
from skfuzzy import control as ctrl
conf = ctrl.Antecedent(np.arange(0.0, 1, 0.1), 'conf')
acur = ctrl.Antecedent(np.arange(0.0, 1, 0.1), 'acur')
lat = ctrl.Antecedent(np.arange(0.0, 1, 0.1), 'lat')
ef = ctrl.Antecedent(np.arange(0.0, 1, 0.1), 'ef')
grau = ctrl.Consequent(np.arange(0.0, 1, 0.1), 'grau')
conf['poor'] = fuzz.trimf(grau.universe, [0, 0, 0.3])
conf['average'] = fuzz.trimf(grau.universe, [0.25, 0.5, 0.75])
conf['good'] = fuzz.trimf(grau.universe, [0.7, 1.0, 1.0])
acur['poor'] = fuzz.trimf(grau.universe, [0, 0, 0.3])
acur['average'] = fuzz.trimf(grau.universe, [0.25, 0.5, 0.75])
acur['good'] = fuzz.trimf(grau.universe, [0.7, 1.0, 1.0])
lat['good'] = fuzz.trimf(grau.universe, [0, 0, 0.3])
lat['average'] = fuzz.trimf(grau.universe, [0.25, 0.5, 0.75])
lat['poor'] = fuzz.trimf(grau.universe, [0.7, 1.0, 1.0])
ef['poor'] = fuzz.trimf(grau.universe, [0, 0, 0.3])
ef['average'] = fuzz.trimf(grau.universe, [0.25, 0.5, 0.75])
ef['good'] = fuzz.trimf(grau.universe, [0.7, 1.0, 1.0])
grau['insuficiente'] = fuzz.trimf(grau.universe, [0, 0, 0.05])
grau['Muito ruim'] = fuzz.trimf(grau.universe, [0.04, 0.13, 0.2])
grau['Ruim'] = fuzz.trimf(grau.universe, [0.19, 0.3, 0.45])
grau['Regular'] = fuzz.trimf(grau.universe, [0.44, 0.54, 0.64])
grau['Bom'] = fuzz.trimf(grau.universe, [0.6, 0.65, 0.75])
grau['Muito Bom'] = fuzz.trimf(grau.universe, [0.74, 0.82, 0.95])
grau['Ótimo'] = fuzz.trimf(grau.universe, [0.94, 1, 1])
rule1 = ctrl.Rule(conf['poor'] and acur['poor'] and lat['good'] and ef['poor'], grau['insuficiente'])
rule2 = ctrl.Rule(conf['poor'] and acur['poor'] and lat['good'] and ef['average'], grau['Muito ruim'])
rule3 = ctrl.Rule(conf['poor'] and acur['poor'] and lat['good'] and ef['good'], grau['Ruim'])
rule4 = ctrl.Rule(conf['poor'] and acur['poor'] and lat['average'] and ef['poor'], grau['Muito ruim'])
rule5 = ctrl.Rule(conf['poor'] and acur['poor'] and lat['average'] and ef['average'], grau['Ruim'])
rule6 = ctrl.Rule(conf['poor'] and acur['poor'] and lat['average'] and ef['good'], grau['Ruim'])
rule7 = ctrl.Rule(conf['poor'] and acur['poor'] and lat['poor'] and ef['poor'], grau['Muito ruim'])
rule8 = ctrl.Rule(conf['poor'] and acur['poor'] and lat['poor'] and ef['average'], grau['Ruim'])
rule9 = ctrl.Rule(conf['poor'] and acur['poor'] and lat['poor'] and ef['good'], grau['Regular'])
rule10 = ctrl.Rule(conf['poor'] and acur['average'] and lat['good'] and ef['poor'], grau['insuficiente'])
rule11 = ctrl.Rule(conf['poor'] and acur['average'] and lat['good'] and ef['average'], grau['Muito ruim'])
rule12 = ctrl.Rule(conf['poor'] and acur['average'] and lat['good'] and ef['good'], grau['Ruim'])
rule13 = ctrl.Rule(conf['poor'] and acur['average'] and lat['average'] and ef['poor'], grau['Muito ruim'])
rule14 = ctrl.Rule(conf['poor'] and acur['average'] and lat['average'] and ef['average'], grau['Ruim'])
rule15 = ctrl.Rule(conf['poor'] and acur['average'] and lat['average'] and ef['good'], grau['Regular'])
rule16 = ctrl.Rule(conf['poor'] and acur['average'] and lat['poor'] and ef['poor'], grau['Ruim'])
rule17 = ctrl.Rule(conf['poor'] and acur['average'] and lat['poor'] and ef['average'], grau['Ruim'])
rule18 = ctrl.Rule(conf['poor'] and acur['average'] and lat['poor'] and ef['good'], grau['Regular'])
rule19 = ctrl.Rule(conf['poor'] and acur['good'] and lat['good'] and ef['poor'], grau['Muito ruim'])
rule20 = ctrl.Rule(conf['poor'] and acur['good'] and lat['good'] and ef['average'], grau['Ruim'])
rule21 = ctrl.Rule(conf['poor'] and acur['good'] and lat['good'] and ef['good'], grau['Ruim'])
rule22 = ctrl.Rule(conf['poor'] and acur['good'] and lat['average'] and ef['poor'], grau['Muito ruim'])
rule23 = ctrl.Rule(conf['poor'] and acur['good'] and lat['average'] and ef['average'], grau['Ruim'])
rule24 = ctrl.Rule(conf['poor'] and acur['good'] and lat['average'] and ef['good'], grau['Regular'])
rule25 = ctrl.Rule(conf['poor'] and acur['good'] and lat['poor'] and ef['poor'], grau['Ruim'])
rule26 = ctrl.Rule(conf['poor'] and acur['good'] and lat['poor'] and ef['average'], grau['Regular'])
rule27 = ctrl.Rule(conf['poor'] and acur['good'] and lat['poor'] and ef['good'], grau['Bom'])
rule28 = ctrl.Rule(conf['average'] and acur['poor'] and lat['good'] and ef['poor'], grau['Muito ruim'])
rule29 = ctrl.Rule(conf['average'] and acur['poor'] and lat['good'] and ef['average'], grau['Ruim'])
rule30 = ctrl.Rule(conf['average'] and acur['poor'] and lat['good'] and ef['good'], grau['Regular'])
rule31 = ctrl.Rule(conf['average'] and acur['poor'] and lat['average'] and ef['poor'], grau['Ruim'])
rule32 = ctrl.Rule(conf['average'] and acur['poor'] and lat['average'] and ef['average'], grau['Regular'])
rule33 = ctrl.Rule(conf['average'] and acur['poor'] and lat['average'] and ef['good'], grau['Bom'])
rule34 = ctrl.Rule(conf['average'] and acur['poor'] and lat['poor'] and ef['poor'], grau['Ruim'])
rule35 = ctrl.Rule(conf['average'] and acur['poor'] and lat['poor'] and ef['average'], grau['Regular'])
rule36 = ctrl.Rule(conf['average'] and acur['poor'] and lat['poor'] and ef['good'], grau['Bom'])
rule37 = ctrl.Rule(conf['average'] and acur['average'] and lat['good'] and ef['poor'], grau['Ruim'])
rule38 = ctrl.Rule(conf['average'] and acur['average'] and lat['good'] and ef['average'], grau['Ruim'])
rule39 = ctrl.Rule(conf['average'] and acur['average'] and lat['good'] and ef['good'], grau['Regular'])
rule40 = ctrl.Rule(conf['average'] and acur['average'] and lat['average'] and ef['poor'], grau['Ruim'])
rule41 = ctrl.Rule(conf['average'] and acur['average'] and lat['average'] and ef['average'], grau['Regular'])
rule42 = ctrl.Rule(conf['average'] and acur['average'] and lat['average'] and ef['good'], grau['Bom'])
rule43 = ctrl.Rule(conf['average'] and acur['average'] and lat['poor'] and ef['poor'], grau['Regular'])
rule44 = ctrl.Rule(conf['average'] and acur['average'] and lat['poor'] and ef['average'], grau['Bom'])
rule45 = ctrl.Rule(conf['average'] and acur['average'] and lat['poor'] and ef['good'], grau['Bom'])
rule46 = ctrl.Rule(conf['average'] and acur['good'] and lat['good'] and ef['poor'], grau['Ruim'])
rule47 = ctrl.Rule(conf['average'] and acur['good'] and lat['good'] and ef['average'], grau['Regular'])
rule48 = ctrl.Rule(conf['average'] and acur['good'] and lat['good'] and ef['good'], grau['Bom'])
rule49 = ctrl.Rule(conf['average'] and acur['good'] and lat['average'] and ef['poor'], grau['Ruim'])
rule50 = ctrl.Rule(conf['average'] and acur['good'] and lat['average'] and ef['average'], grau['Regular'])
rule51 = ctrl.Rule(conf['average'] and acur['good'] and lat['average'] and ef['good'], grau['Bom'])
rule52 = ctrl.Rule(conf['average'] and acur['good'] and lat['poor'] and ef['poor'], grau['Regular'])
rule53 = ctrl.Rule(conf['average'] and acur['good'] and lat['poor'] and ef['average'], grau['Bom'])
rule54 = ctrl.Rule(conf['average'] and acur['good'] and lat['poor'] and ef['good'], grau['Muito Bom'])
rule55 = ctrl.Rule(conf['good'] and acur['poor'] and lat['good'] and ef['poor'], grau['Ruim'])
rule56 = ctrl.Rule(conf['good'] and acur['poor'] and lat['good'] and ef['average'], grau['Regular'])
rule57 = ctrl.Rule(conf['good'] and acur['poor'] and lat['good'] and ef['good'], grau['Bom'])
rule58 = ctrl.Rule(conf['good'] and acur['poor'] and lat['average'] and ef['poor'], grau['Regular'])
rule59 = ctrl.Rule(conf['good'] and acur['poor'] and lat['average'] and ef['average'], grau['Bom'])
rule60 = ctrl.Rule(conf['good'] and acur['poor'] and lat['average'] and ef['good'], grau['Muito Bom'])
rule61 = ctrl.Rule(conf['good'] and acur['poor'] and lat['poor'] and ef['poor'], grau['Bom'])
rule62 = ctrl.Rule(conf['good'] and acur['poor'] and lat['poor'] and ef['average'], grau['Bom'])
rule63 = ctrl.Rule(conf['good'] and acur['poor'] and lat['poor'] and ef['good'], grau['Muito Bom'])
rule64 = ctrl.Rule(conf['good'] and acur['average'] and lat['good'] and ef['poor'], grau['Regular'])
rule65 = ctrl.Rule(conf['good'] and acur['average'] and lat['good'] and ef['average'], grau['Bom'])
rule66 = ctrl.Rule(conf['good'] and acur['average'] and lat['good'] and ef['good'], grau['Bom'])
rule67 = ctrl.Rule(conf['good'] and acur['average'] and lat['average'] and ef['poor'], grau['Regular'])
rule68 = ctrl.Rule(conf['good'] and acur['average'] and lat['average'] and ef['average'], grau['Bom'])
rule69 = ctrl.Rule(conf['good'] and acur['average'] and lat['average'] and ef['good'], grau['Muito Bom'])
rule70 = ctrl.Rule(conf['good'] and acur['average'] and lat['poor'] and ef['poor'], grau['Bom'])
rule71 = ctrl.Rule(conf['good'] and acur['average'] and lat['poor'] and ef['average'], grau['Muito Bom'])
rule72 = ctrl.Rule(conf['good'] and acur['average'] and lat['poor'] and ef['good'], grau['Ótimo'])
rule73 = ctrl.Rule(conf['good'] and acur['good'] and lat['good'] and ef['poor'], grau['Regular'])
rule74 = ctrl.Rule(conf['good'] and acur['good'] and lat['good'] and ef['average'], grau['Bom'])
rule75 = ctrl.Rule(conf['good'] and acur['good'] and lat['good'] and ef['good'], grau['Muito Bom'])
rule76 = ctrl.Rule(conf['good'] and acur['good'] and lat['good'] and ef['poor'], grau['Bom'])
rule77 = ctrl.Rule(conf['good'] and acur['good'] and lat['average'] and ef['average'], grau['Bom'])
rule78 = ctrl.Rule(conf['good'] and acur['good'] and lat['average'] and ef['good'], grau['Muito Bom'])
rule79 = ctrl.Rule(conf['good'] and acur['good'] and lat['average'] and ef['poor'], grau['Bom'])
rule80 = ctrl.Rule(conf['good'] and acur['good'] and lat['poor'] and ef['average'], grau['Muito Bom'])
rule81 = ctrl.Rule(conf['good'] and acur['good'] and lat['poor'] and ef['good'], grau['Ótimo'])
tipping_ctrl = ctrl.ControlSystem([rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule8, rule9, rule10,
rule11, rule12, rule13, rule14, rule15, rule16, rule17, rule18, rule19, rule20,
rule21, rule22, rule23, rule24, rule25, rule26, rule27, rule28, rule29, rule30,
rule31, rule32, rule33, rule34, rule35, rule36, rule37, rule38, rule39, rule40,
rule41, rule42, rule43, rule44, rule45, rule46, rule47, rule48, rule49, rule50,
rule51, rule52, rule53, rule54, rule55, rule56, rule57, rule58, rule59, rule60,
rule61, rule62, rule63, rule64, rule65, rule66, rule67, rule68, rule69, rule70,
rule71, rule72, rule73, rule74, rule75, rule76, rule77, rule78, rule79, rule80, rule81])
tipping = ctrl.ControlSystemSimulation(tipping_ctrl)
tipping.input['conf'] = 0.2
tipping.input['acur'] = 1.0
tipping.input['lat'] = 1.0
tipping.input['ef'] = 0
tipping.compute()
print(tipping.output['Grau'])