Scikit fuzzy rule formation cannot be done due to this error. Skfuzzy code and error message is shown below
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
inside the rule.py module digraph object is created and add_path attribute is referenced from digraph object instead of networkx object. When I changed the reference to networkx object the error shows up saying add_path requires more attributes.
You hit the issue described at https://github.com/scikit-fuzzy/scikit-fuzzy/pull/230
Update to latest release 0.4.2
pip install git+git://github.com/scikit-fuzzy/scikit-fuzzy.git