digraph对象没有属性'add_path'

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了digraph对象没有属性'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模块中,有向图对象被创建,并且从有向图对象而不是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

以上是关于digraph对象没有属性'add_path'的主要内容,如果未能解决你的问题,请参考以下文章

Python属性错误'Map'对象没有属性'cells'

AttributeError:'str'对象没有属性'author'

对象没有属性'split()' Python

我遇到错误:AttributeError:'str'对象没有属性'isfloat'

'numpy.ndarray'对象没有属性'index'

'Page'对象没有属性'ordered'异常