您好我试图通过scikit-fuzzy制作模糊系统,输出似乎运行良好但是当我尝试根据scikit-fuzzy新api来计算它时,我的情节没有响应。我记得上次当我使用scikit-fuzzy时我的情节运行良好,什么错了?我的代码缺少什么吗?
import numpy as np
import skfuzzy as fuzz
from skfuzzy import control as ctrl
# crisp set
keramaian = ctrl.Antecedent(np.arange(0, 30, 1), 'KERAMAIAN')
ukuran = ctrl.Antecedent(np.arange(0, 25, 1), 'UKURAN')
vol = ctrl.Consequent(np.arange(0, 100, 1), 'UKURAN VOLUME')
# fuzzyfication
ukuran['Kecil'] = fuzz.trimf(ukuran.universe, [0, 0, 13])
ukuran['Sedang'] = fuzz.trimf(ukuran.universe, [0, 12, 24])
ukuran['Besar'] = fuzz.trimf(ukuran.universe, [12, 24, 24])
keramaian['sunyi'] = fuzz.trimf(keramaian.universe, [0, 0, 15])
keramaian['Cukup Ramai'] = fuzz.trimf(keramaian.universe, [0, 15, 29])
keramaian['Berisik'] = fuzz.trimf(keramaian.universe, [15, 29, 29])
vol['Pelan'] = fuzz.trimf(vol.universe, [0, 0, 40])
vol['Sedang'] = fuzz.trimf(vol.universe, [30, 50, 70])
vol['Kencang'] = fuzz.trimf(vol.universe, [60, 99, 99])
# rule set
rule1 = ctrl.Rule(ukuran['Kecil'] & keramaian['Berisik'], vol['Kencang'])
rule2 = ctrl.Rule(ukuran['Kecil'] & keramaian['Cukup Ramai'], vol['Kencang'])
rule3 = ctrl.Rule(ukuran['Kecil'] & keramaian['Cukup Ramai'], vol['Kencang'])
rule4 = ctrl.Rule(ukuran['Sedang'] & keramaian['Berisik'], vol['Sedang'])
rule5 = ctrl.Rule(ukuran['Sedang'] & keramaian['Cukup Ramai'], vol['Sedang'])
rule6 = ctrl.Rule(ukuran['Sedang'] & keramaian['sunyi'], vol['Sedang'])
rule7 = ctrl.Rule(ukuran['Besar'] & keramaian['Berisik'], vol['Pelan'])
rule8 = ctrl.Rule(ukuran['Besar'] & keramaian['Cukup Ramai'], vol['Pelan'])
rule9 = ctrl.Rule(ukuran['Besar'] & keramaian['sunyi'], vol['Pelan'])
vol_suara_ctrl = ctrl.ControlSystem([rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule8, rule9])
vol_suara = ctrl.ControlSystemSimulation(vol_suara_ctrl)
keramaian['sunyi'].view()
vol_suara.input['KERAMAIAN'] = int(input("Masukkan jumlah keramaian?\n"))
vol_suara.input['UKURAN'] = int(input("Masukkan ukuran speaker?\n"))
# defuzification
vol_suara.compute()
vol.view(sim=vol_suara)
print(vol_suara.output['UKURAN VOLUME'])
答案 0 :(得分:0)
导入import matplotlib.pyplot as plt
并尝试在代码末尾使用plt.show()
。