二合字母对象没有属性 'add_path'
digraph object has no attribute 'add_path'
由于此错误,无法形成 Scikit 模糊规则。 skfuzzy 代码和报错信息如下所示
import matplotlib.pyplot as pit
import skfuzzy as fuz
import numpy as np
from skfuzzy import control as ctrl
s=ctrl.Antecedent(np.arange(0,11,1),'service')
q=ctrl.Antecedent(np.arange(0,11,1),'quality')
t=ctrl.Antecedent(np.arange(0,26,1),'tip')
s.automf(3)
q.automf(3)
t['low']=fuz.trimf(t.universe,[0,0,13])
t['medium']=fuz.trimf(t.universe,[0,13,25])
t['high']=fuz.trimf(t.universe,[13,25,25])
rule1=ctrl.Rule(q['poor'] | s['poor'], t['low'])
rule2=ctrl.Rule(q['poor'] | s['average'], t['medium'])
rule3=ctrl.Rule(q['poor'] | s['good'], t['high'])
tip_ctrl=ctrl.ControlSystem([rule1,rule2, rule3])
tip=ctrl.ControlSystemSimulation(tip_ctrl)
tip.input['service']=2.1
tip.input['quality']=5.6
tip.compute()
print(tip.output['t'])
#tip.view(sim=tip)
#pit.show()
Traceback (most recent call last):
File "/home/amavasi/.vscode/extensions/ms-python.python-2019.11.49689/pythonFiles/ptvsd_launcher.py", line 43, in <module>
main(ptvsdArgs)
File "/home/amavasi/.vscode/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 432, in main
run()
File "/home/amavasi/.vscode/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 316, in run_file
runpy.run_path(target, run_name='__main__')
File "/usr/lib/python3.7/runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "/usr/lib/python3.7/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/amavasi/Public/ruthu/skfuzzy learn.py", line 22, in <module>
tip_ctrl=ctrl.ControlSystem([rule1,rule2, rule3])
File "/home/amavasi/.local/lib/python3.7/site-packages/skfuzzy/control/controlsystem.py", line 47, in __init__
self.addrule(rule)
File "/home/amavasi/.local/lib/python3.7/site-packages/skfuzzy/control/controlsystem.py", line 107, in addrule
self.graph = nx.compose(self.graph, rule.graph)
File "/home/amavasi/.local/lib/python3.7/site-packages/skfuzzy/control/rule.py", line 295, in graph
graph.add_path([t, self])
AttributeError: 'DiGraph' object has no attribute 'add_path'
Terminated
在 rule.py 模块内部创建了 digraph 对象,并且从 digraph 对象而不是 networkx 对象引用了 add_path 属性。当我更改对 networkx 对象的引用时,错误显示 add_path 需要更多属性。
您遇到了描述的问题
https://github.com/scikit-fuzzy/scikit-fuzzy/pull/230
更新到最新版本 0.4.2
pip install git+git://github.com/scikit-fuzzy/scikit-fuzzy.git
由于此错误,无法形成 Scikit 模糊规则。 skfuzzy 代码和报错信息如下所示
import matplotlib.pyplot as pit
import skfuzzy as fuz
import numpy as np
from skfuzzy import control as ctrl
s=ctrl.Antecedent(np.arange(0,11,1),'service')
q=ctrl.Antecedent(np.arange(0,11,1),'quality')
t=ctrl.Antecedent(np.arange(0,26,1),'tip')
s.automf(3)
q.automf(3)
t['low']=fuz.trimf(t.universe,[0,0,13])
t['medium']=fuz.trimf(t.universe,[0,13,25])
t['high']=fuz.trimf(t.universe,[13,25,25])
rule1=ctrl.Rule(q['poor'] | s['poor'], t['low'])
rule2=ctrl.Rule(q['poor'] | s['average'], t['medium'])
rule3=ctrl.Rule(q['poor'] | s['good'], t['high'])
tip_ctrl=ctrl.ControlSystem([rule1,rule2, rule3])
tip=ctrl.ControlSystemSimulation(tip_ctrl)
tip.input['service']=2.1
tip.input['quality']=5.6
tip.compute()
print(tip.output['t'])
#tip.view(sim=tip)
#pit.show()
Traceback (most recent call last):
File "/home/amavasi/.vscode/extensions/ms-python.python-2019.11.49689/pythonFiles/ptvsd_launcher.py", line 43, in <module>
main(ptvsdArgs)
File "/home/amavasi/.vscode/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 432, in main
run()
File "/home/amavasi/.vscode/extensions/ms-python.python-2019.11.49689/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 316, in run_file
runpy.run_path(target, run_name='__main__')
File "/usr/lib/python3.7/runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "/usr/lib/python3.7/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/amavasi/Public/ruthu/skfuzzy learn.py", line 22, in <module>
tip_ctrl=ctrl.ControlSystem([rule1,rule2, rule3])
File "/home/amavasi/.local/lib/python3.7/site-packages/skfuzzy/control/controlsystem.py", line 47, in __init__
self.addrule(rule)
File "/home/amavasi/.local/lib/python3.7/site-packages/skfuzzy/control/controlsystem.py", line 107, in addrule
self.graph = nx.compose(self.graph, rule.graph)
File "/home/amavasi/.local/lib/python3.7/site-packages/skfuzzy/control/rule.py", line 295, in graph
graph.add_path([t, self])
AttributeError: 'DiGraph' object has no attribute 'add_path'
Terminated
在 rule.py 模块内部创建了 digraph 对象,并且从 digraph 对象而不是 networkx 对象引用了 add_path 属性。当我更改对 networkx 对象的引用时,错误显示 add_path 需要更多属性。
您遇到了描述的问题 https://github.com/scikit-fuzzy/scikit-fuzzy/pull/230
更新到最新版本 0.4.2
pip install git+git://github.com/scikit-fuzzy/scikit-fuzzy.git