了解基本模糊逻辑-期望双射函数

时间:2019-11-19 16:54:41

标签: python numpy fuzzy-logic

试图理解模糊逻辑,有人可以解释为什么这两个规则

good quality -> high score

bad quality -> low score

已计算,是否不返回质量为1的100%分数和质量为0的0%分数?尽管所有关系都是线性的?

请参见下面的示例代码:

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

# Input is a "Quality" value from [0..1]
quality = ctrl.Antecedent(np.arange(0, 1.01, 0.01), 'quality')
quality['bad'] = fuzz.trimf(quality.universe, [0,0,1])
quality['good'] = fuzz.trimf(quality.universe, [0,1,1])
#quality.view()

# Output is a "Score" value from [0..100]
score = ctrl.Consequent(np.arange(0, 101, 1), 'score')
score['high'] = fuzz.trimf(score.universe, [0, 100, 100])
score['low'] = fuzz.trimf(score.universe, [0, 0, 100])
#score.view()

# Obvious rules: good quality -> high score, bad quality -> low score
rule1 = ctrl.Rule(quality['good'], score['high'])
rule2 = ctrl.Rule(quality['bad'], score['low'])

#rule1.view()
#rule2.view()

scoring_ctrl = ctrl.ControlSystem([rule1, rule2])
scoring = ctrl.ControlSystemSimulation(scoring_ctrl, cache=False)


scoring.input['quality'] = np.arange(0,1.1,0.1)
scoring.compute()
res=scoring.output['score']

import matplotlib.pyplot as plt
plt.plot(np.arange(0,1.1,0.1), scoring.output['score'])

enter image description here

我应该如何为双射关系建模[0..1]-> [0..100]?

0 个答案:

没有答案