Giter Site home page Giter Site logo

scikit-fuzzy's Introduction

scikit-fuzzy

scikit-fuzzy is a fuzzy logic toolkit for SciPy.

The goals of scikit-fuzzy are:

  • To provide the community with a robust toolkit of independently developed and implemented fuzzy logic algorithms
  • To increase the attractiveness of scientific Python as a valid alternative to closed-source options.

Please cite DOI if you find scikit-fuzzy useful. A formal paper describing this package is in preparation.

Source

https://github.com/scikit-fuzzy/scikit-fuzzy

Documentation

The documentation of the library can be found here: https://scikit-fuzzy.github.io/scikit-fuzzy/

Online Discussion & Mailing List

Please join the discussion in our public chat room on Gitter.im Gitter

or view/post on the Google Groups mailing list http://groups.google.com/group/scikit-fuzzy

Installation

Scikit-Fuzzy depends on

  • Matplotlib >= 3.1
  • NumPy >= 1.6
  • SciPy >= 0.9
  • NetworkX >= 1.9

and is available on PyPi! The latest stable release can always be obtained and installed simply by running

$ pip install -U scikit-fuzzy

which will also work to upgrade existing installations to the latest release.

If you prefer to install from source or develop this package, you can fork and clone this repository then install SciKit-Fuzzy by running

$ pip install -e .

or develop locally by running

$ pip install -e ".[develop]"

If you prefer, you can use SciKit-Fuzzy without installing by simply exporting this path to your PYTHONPATH variable.

License

Please read LICENSE.txt in this directory.

IEEE Rounding for Matlab users

It should be noted that Matlab rounds incorrectly. The IEEE standard (which is how this package behaves) requires rounding to the nearest EVEN number if exactly between, e.g. 1.5 --> 2; 2.5 --> 2; 3.5 --> 4; 4.5 --> 4, etc. This minimizes systematic rounding error. Thus, if re-implementing algorithms from Matlab code, slight inconsistencies in rounded results are expected. These are not bugs, and will not be fixed.

scikit-fuzzy's People

Contributors

99991 avatar alexbuy avatar alexsavio avatar arruda avatar axelande avatar balins avatar castelao avatar cclauss avatar fmmb avatar freakwill avatar gitter-badger avatar guillem96 avatar jdwarner avatar jfpower avatar jsexauer avatar katanachan avatar kinow avatar laurazh avatar marcomiretti avatar moetayuko avatar nicksspirit avatar nilp0inter avatar orkohunter avatar pd2f avatar phme283 avatar scikit-fuzzy avatar tjni avatar tuelwer avatar twmeggs avatar wouter-vdb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scikit-fuzzy's Issues

Plotting problem

Hi,
I am using Python 3.5.2
First I tried plot_tipping_problem.py, but I had a plotting problem: it doesn't show nothing. So I decided to insert a plt.show() at the end and it works for me.
Now I am trying plot_tipping_problem_newappi.py and I have a similar problem: it doesn't show any figure, although it prints the tip at the end (I had to put the prints argument inside parethesis, but this is because of the Python version). The situation is that I can't use the same solution, plt.show(), to see the figures because it is not using matplotlib. What can I do?
Thank you in advance
Andres

Add check for overly sparse system

@nilayrox18 recently reported an error with this system:

import numpy as np
import skfuzzy as fuzz

quality = fuzz.Antecedent(np.arange(0,11,1),'quality')
service = fuzz.Antecedent(np.arange(0,11,1),'service')

tip = fuzz.Consequent(np.arange(0,26,1),'tip')

quality.automf(3)
service.automf(3)
tip.automf(3)

quality.view()
service.view()
tip.view()

rule1 = fuzz.Rule(quality['poor'] | service['poor'],tip['poor'])
rule2 = fuzz.Rule(quality['good'] | service['good'],tip['good'])

tip_cnt = fuzz.ControlSystem([rule1, rule2])

tipp = fuzz.ControlSystemSimulation(tip_cnt)

tipp.input['quality'] = 5
tipp.input['service'] = 5

tipp.compute()  # Error here

The problem is that for the chosen input values - which are both 5, exactly in the middle of both fuzzy antecedents - neither 'poor' nor 'good' membership functions are active. Thus, there is nothing for the fuzzy system to respond to!

On my system using current master, I get the following traceback:

     25 tipp.input['service'] = 5
     26 
---> 27 tipp.compute()

/home/jdwarner/src/scikit-fuzzy/skfuzzy/control/controlsystem.py in compute(self)
    160         for consequent in self.ctrl.consequents:
    161             consequent.output[self] = \
--> 162                 CrispValueCalculator(consequent, self).defuzz()

/home/jdwarner/src/scikit-fuzzy/skfuzzy/control/controlsystem.py in defuzz(self)
    282                              "have at least one rule connected to this "
    283                              "variable and have run the rules calculation.")
--> 284         return defuzz(self.var.universe, output_mf, self.var.defuzzify_method)

/home/jdwarner/src/scikit-fuzzy/skfuzzy/defuzzify/defuzz.pyc in defuzz(x, mfx, mode)
    130     if 'centroid' in mode or 'bisector' in mode:
    131         tot_area = mfx.sum()
--> 132         assert tot_area != 0, 'Total area is zero in defuzzification!'

AssertionError: Total area is zero in defuzzification!

There should be a more useful error here, telling the user that for the given inputs all antecedents are returning an activity of zero and the system result cannot be computed. Suggesting their ruleset might be too sparse in the message would give them a much clearer path forward.

We could also return the mean of the consequent(s) in this case, but I'd feel better raising an exception.

skfuzzy.Antecedents not working!!!

Traceback (most recent call last):
File "FCS.py", line 9, in
quality = skfuzzy.Antecedent(np.arange(0, 11, 1), 'quality')
AttributeError: 'module' object has no attribute 'Antecedent'

Can anyone resolve this issue

Can't change the defuzzify method

I don't know if there's another way to do that, but I haven't found a way of changing the defuzzify method that is not editing the code itself.

In the example below:

quality = ctrl.Antecedent(np.arange(0,11,1),'quality')
service = ctrl.Antecedent(np.arange(0,11,1),'service')
tip = ctrl.Consequent(np.arange(0,26,1),'tip')

The defuzzify method is centroid by default. That happens because such is defined in FuzzyVariable class, but since it's a superclass it's not very practical to use it.

Just for a test, I added the defuzzify_method variable in Consequent constructor, like this:

def __init__(self, universe, label, defuzzyfy_method='centroid'):
        """""" + Consequent.__doc__
        super(Consequent, self).__init__(universe, label, defuzzyfy_method)
        self.__name__ = 'Consequent'

Now, for the example above, I was able to do something like:

quality = ctrl.Antecedent(np.arange(0,11,1),'quality')
service = ctrl.Antecedent(np.arange(0,11,1),'service')
tip = ctrl.Consequent(np.arange(0,26,1),'tip','bisector')

If there's another way to do that (which I didn't notice), I apologize.

Documentation View Rule

Is there any documentation regarding the meaning of the rule diagram displayed by rule.view()?

What are all of those red dots connected..it seems like a directed graph without any meaning ..at least I dont understand the meaning of the diagram in tipping example... any documentation available?

Improvements to Rule Calculation Order for Intermediaries

The current way the control module figures out the order to process rules is based on if the terms that are in the predicate of the rule have been fully calculated at least once. This is not a good implementation because:

  • It produces inconsistent results when multiple rules drive the same variable's term. Eg:
rule1 = fuzz.Rule(service['good'], tip['good'])
rule2 = fuzz.Rule(quality['good'], tip['good'])
  • It produces inconsistent results when multiple rules drive the same variable and the membership functions of the term overlaps. Eg:
tip['good'] = fuzz.trimf(tip.universe, [13, 25, 25])
tip['fair'] = fuzz.trimf(tip.universe, [10, 20, 25]) # Exaggerated overlap in membership
rule1 = fuzz.Rule(service['good'], tip['good'])
rule2 = fuzz.Rule(quality['good'], tip['fair'])

Note that these limitations only affect intermediary variables.

A better approach is to ensure all rules which drive the input side of an intermediary (regardless of term) are calculated before any rules which use the intermediary in the predicate.

Warnings: no files found matching ...

warning: no files found matching '*.pyx' under directory 'skfuzzy'
warning: no files found matching '*.pxd' under directory 'skfuzzy'
warning: no files found matching '*.pxi' under directory 'skfuzzy'
warning: no files found matching '*.c' under directory 'skfuzzy'
warning: no files found matching '*.h' under directory 'skfuzzy'
warning: no files found matching '*.ini' under directory 'skfuzzy'
warning: no files found matching '*.md5' under directory 'skfuzzy'
no previously-included directories found matching 'docs/build'
no previously-included directories found matching 'docs/gh-pages'

Found on FreeBSD 11.1.

Fuzzy C-means clustering of Glove vectors

I have run K-means clustering of Glove semantic vectors, which works fine shown in this link with explanation and full source . I applied fuzzy C-means algorithm instead of K-means to compare results, however, it shows me errors. I really could not find why this code is not working. I have only changed the full source above only in part which is Fuzzy C-means implementation. So, this is what I wrote as an FCM: `

if name == "main":

    input_vector_file = sys.argv[1]
    n_words           = int(sys.argv[2])
    reduction_factor  = float(sys.argv[3])
    clusters_to_make  = int( n_words * reduction_factor )
    labels_array = build_word_vector_matrix(input_vector_file, n_words)
    for c, r in enumerate(input_vector_file):
        sr = r.split()
        labels_array_aslist=list(labels_array)
        cluster_labels=labels_array_aslist.append(sr[0])

    Fuzzy_C_means_model = fuzz.cluster.cmeans(input_vector_file, clusters_to_make, 2, error=0.005, maxiter=1000,init=None)
    cluster_to_words = find_word_clusters(labels_array, cluster_labels)


    for c in cluster_to_words:
       print (cluster_to_words[c])`

But it shows

n = data.shape[1]
AttributeError: 'str' object has no attribute 'shape'
error.
Could you tell me how to fix this, please ?

Improve control module documenation

  • Several docstrings are missing from the new classes I added
  • Improve PythonHosted documentation to include a fuzzy control primer and tipping problem example using the control module (I have this mostly written already) -- Probably shouldn't be done until the API is in a bit more stable condition

Fuzzy Logic Design

Dear All,
Firstly, I'd like to express my gratitude to Dr.Josh for his efforts of building this API and for his cooperation by answering our questions. Secondly, I am facing problem in the fuzzy design. I am just wondering whether this definition of the output membership function is right or not:

trust_hi = fuzz.trimf(x_trust, [0, 0, 0.25])
trust_mh = fuzz.trimf(x_trust, [0,0.25,0.5])
trust_md = fuzz.trimf(x_trust, [0.25,0.5,0.75])
trust_ml = fuzz.trimf(x_trust, [0.5,0.75, 1])
trust_lo = fuzz.trimf(x_trust, [0.75, 1, 1])
output

Regards
Mohammed

Problem with view() function

I am using skfuzzy with python 2.7.x. Every time I call view() function (i.e; quality['average'].view()), just a blink like phenomenon comes. Could not find why.

wrong gaussmf

The gaussian membership function is defined as

gaussmf

and yet the code that actually computes it is
return np.exp(-((x - mean) ** 2.) / float(sigma) ** 2.)

the denominator should be multiplied by 2.

Bug in defuzzify.defuzz.lambda_cut_series

Original code:

z[:, 0] = lambda_cuts.T
z[0, [1, 2]] = _support(x, mfx)
print z[0, [1, 2]]
for ii in range(N):
    xx = _lcutinterval(x, mfx, lambda_cuts[ii])
    z[ii, [1, 2]] = xx

New:

z[:, 0] = lambda_cuts.T
z[0, [1, 2]] = _support(x, mfx)
print z[0, [1, 2]]
for ii in range(1,N):
    xx = _lcutinterval(x, mfx, lambda_cuts[ii])
    z[ii, [1, 2]] = xx

So tho for loop itereates only between 1 and N.
Otherwise the support is overwritten with the bounds of x.

Allow recalculation within a ControlSystemSimulation

If one changes input values, then executes simulation.compute() again, the system should recalculate - fully, if needed - instead of raising an exception.

Addressing this issue does not require caching (see separate Issue #74), just that a new set of inputs will propagate through correctly.

The naive user will not expect to need to regenerate a new object. For most users, especially anyone doing real-time control, minimal latency is a design goal. Requiring construction of a new simulation object every time is not ideal.

Caching of partial results in `skfuzzy.control`

Execution of the fuzzy system should only recalculate needed quantities given changed values. Tracking which inputs have changed, along with the inbuilt networkx graph, makes this possible.

Multiple Rules converging on single Consequent should combine, not overwrite

This affects systems where several Rules all name the same Consequent Term as output.

Currently, all Rules are evaluated individually and then those results are directly written to the appropriate Consequent Term. This results in prior results being overwritten. They should instead be combined using np.fmax.

I've confirmed this is the true issue underlying two recent reports on the mailing list.

The necessary fix is pending.

Documentation

Hi! Is there any documentation page yet? I was unable to find it in the README file.

If not, then setting up a hook on readthedocs.org would be a cool idea.

Documentation build issues

Howdy devs, Would it be possible to:

  • turn on readthedocs for sk-fuzzy?
  • provide a full requirements.txt (numpy, scipy, scikit-image, matplotlib)

I've not actually been able to build the docs myself yet, and would really like to read them in HTML since it looks like really well written documentation

(env)hxr@leda:~/work/scikit-fuzzy/docs$ make html
python tools/build_modref_templates.py
('outdir: ', '')
8 files written
Build API docs...done.
python tools/gitwash/gitwash_dumper.py source scikit-fuzzy \
--project-url=http://scikit-fuzzy.org \
--project-ml-url=http://groups.google.com/group/scikit-fuzzy \
--repo-name=scikit-fuzzy \
--github-user=scikit-fuzzy \
--source-suffix=.txt
Cloning into '/tmp/tmpTTq5J1'...
remote: Counting objects: 649, done.
remote: Total 649 (delta 0), reused 0 (delta 0), pack-reused 649
Receiving objects: 100% (649/649), 216.16 KiB | 0 bytes/s, done.
Resolving deltas: 100% (387/387), done.
Checking connectivity... done.
Already on 'master'
Your branch is up-to-date with 'origin/master'.
python /home/hxr/work/scikit-fuzzy/env/bin/sphinx-build -b html -d build/doctrees   source build/html
Running Sphinx v1.3.1
making output directory...
loading pickled environment... not yet created

Exception occurred:
  File "/home/hxr/work/scikit-fuzzy/docs/ext/plot2rst.py", line 195, in generate_examples_and_gallery
    gallery_index = file(rst_dir.pjoin('index'+cfg.source_suffix), 'w')
TypeError: cannot concatenate 'str' and 'list' objects
The full traceback has been saved in /tmp/sphinx-err-KKSRL0.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
Makefile:49: recipe for target 'html' failed
make: *** [html] Error 1

The traceback

# Sphinx version: 1.3.1
# Python version: 2.7.9 (CPython)
# Docutils version: 0.12 release
# Jinja2 version: 2.7.3
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
  File "/home/hxr/work/scikit-fuzzy/env/local/lib/python2.7/site-packages/sphinx/cmdline.py", line 244, in main
    opts.warningiserror, opts.tags, opts.verbosity, opts.jobs)
  File "/home/hxr/work/scikit-fuzzy/env/local/lib/python2.7/site-packages/sphinx/application.py", line 188, in __init__
    self._init_builder(buildername)
  File "/home/hxr/work/scikit-fuzzy/env/local/lib/python2.7/site-packages/sphinx/application.py", line 250, in _init_builder
    self.emit('builder-inited')
  File "/home/hxr/work/scikit-fuzzy/env/local/lib/python2.7/site-packages/sphinx/application.py", line 497, in emit
    results.append(callback(self, *args))
  File "/home/hxr/work/scikit-fuzzy/docs/ext/plot2rst.py", line 184, in generate_example_galleries
    generate_examples_and_gallery(example_dir, rst_dir, cfg)
  File "/home/hxr/work/scikit-fuzzy/docs/ext/plot2rst.py", line 195, in generate_examples_and_gallery
    gallery_index = file(rst_dir.pjoin('index'+cfg.source_suffix), 'w')
TypeError: cannot concatenate 'str' and 'list' objects

Scikit 0.3 AttributeError

Hi everyone.
On trying to implement the tipping example of the scikit version 0.3, I get this error from exactly the command thus:
tipping_ctrl = ctrl.ControlSystem([rule1, rule2, rule3]) gives:
Traceback (most recent call last):

  File "", line 1, in
    runfile('C:/Python27/Lib/site-packages/skfuzzy/control/tipping.py', wdir='C:/Python27/Lib/site-packages/skfuzzy/control')

  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
    execfile(filename, namespace)

  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "C:/Python27/Lib/site-packages/skfuzzy/control/tipping.py", line 41, in
    tipping_ctrl = ctrl.ControlSystem([rule1, rule2, rule3])

  File "C:\Python27\lib\site-packages\skfuzzy\control\controlsystem.py", line 45, in init
    self.addrule(rule)

  File "C:\Python27\lib\site-packages\skfuzzy\control\controlsystem.py", line 98, in addrule
    for r in self.rules:

  File "C:\Python27\lib\site-packages\skfuzzy\control\controlsystem.py", line 596, in iter
    self._cache = list(self._process_rules(self.all_rules[:]))

  File "C:\Python27\lib\site-packages\skfuzzy\control\controlsystem.py", line 630, in _process_rules
    if self._can_calc_rule(rule):

  File "C:\Python27\lib\site-packages\skfuzzy\control\controlsystem.py", line 658, in _can_calc_rule
    for p in self.all_graph.predecessors_iter(rule):

AttributeError: 'DiGraph' object has no attribute 'predecessors_iter'

Addition of multiple rules

I have 64 fuzzy If-Then rules to add in my fuzzy inference system but I am unable to add more than 2 rules especially the rules with the same consequent cannot be added together. Please help

fuzzifier functions support

Hi
I couldnt find any fuzzification support in cluster module, as in in the paper which talk about problems in fuzzy cmeans with high dimensional data, it is mentioned that PFCM creates an area of crisp membership values.
Am i missing something.

Include a default prediction

Now, if an input does not fire any rule, it throws an exception:
raise ValueError("Crisp output cannot be calculated, likely "...

Instead, it should return a default prediction (assigned to a ControlSystem through a set function), or at least return a None value.

What do you think it should be the best option?
In my opinion, return a default prediction, but if it has not been set previously return a None value.

ControlSystem Debugging Data Structure

Create a new data structure which holds various intermediate results of the controller which can be used for debugging controllers. A poor-man's version of this has been implemented in the ControlSystem.print_state function, but I want to improve this.

Expose methods for fuzzy aggregation and defuzzification in new API framework

@ManolisCh posed this question in #70, but it deserves its own Issue.

Right now (eb15e4c) we assume Mamdani (max/min) inference and centroid defuzzification. That's fine for getting things off the ground, but we should allow the user to select among several methods.

On the backend side, it would be best if these were simple to change in and out. On the user side, comments / thoughts appreciated on the most expressive, intuitive API for exposing different methods for fuzzy aggregation or defuzzification.

For defuzzification, it might be best to take into consideration the upcoming framework for selecting a Sugeno Consequent (see #95) which is not yet in stone.

Off the top of my head:

  • kwargs are always an option, but become cumbersome. If we have good defaults, though, they're usable.
  • Rules and Consequents could expose public .aggregation and .defuzzification properties, which could be one of several options
    • aliases to appropriate function in the package
    • a string ('centroid', 'mamdani', etc.)

That is, assuming these options can be selected or changed after instantiation. If they have to be set on creation, we may be stuck with kwargs.

However, we found a really great way to express rules using neither of these, so please post your thoughts!

Fuzzy Control Systems: The Tipping Problem

I am running this example:
http://pythonhosted.org/scikit-fuzzy/auto_examples/plot_tipping_problem_newapi.html

The problem line is:
rule1.view()

I got error as following:

/usr/local/lib/python3.6/dist-packages/networkx/drawing/nx_pylab.py:126: MatplotlibDeprecationWarning: pyplot.hold is deprecated.
Future behavior will be consistent with the long-time default:
plot commands add elements without first clearing the
Axes and/or Figure.
b = plt.ishold()
/usr/local/lib/python3.6/dist-packages/networkx/drawing/nx_pylab.py:138: MatplotlibDeprecationWarning: pyplot.hold is deprecated.
Future behavior will be consistent with the long-time default:
plot commands add elements without first clearing the
Axes and/or Figure.
plt.hold(b)
/usr/local/lib/python3.6/dist-packages/matplotlib/init.py:917: UserWarning: axes.hold is deprecated. Please remove it from your matplotlibrc and/or style files.
warnings.warn(self.msg_depr_set % key)
/usr/local/lib/python3.6/dist-packages/matplotlib/rcsetup.py:152: UserWarning: axes.hold is deprecated, will be removed in 3.0
warnings.warn("axes.hold is deprecated, will be removed in 3.0")
Traceback (most recent call last):
File "/opt/pycharm/helpers/pydev/pydevd.py", line 1591, in
globals = debugger.run(setup['file'], None, None, is_module)
File "/opt/pycharm/helpers/pydev/pydevd.py", line 1018, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/opt/pycharm/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/matej/Desktop/camps_analysis/code/nextPin/server/spd/scripts/osm_and_camps/ppp.py", line 34, in
rule1.view()
File "/usr/local/lib/python3.6/dist-packages/skfuzzy/control/rule.py", line 247, in view
ControlSystemVisualizer(self).view().show()
AttributeError: 'tuple' object has no attribute 'show'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/init.py", line 5, in
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in
import apt
File "/usr/lib/python3/dist-packages/apt/init.py", line 23, in
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
File "/opt/pycharm/helpers/pydev/pydevd.py", line 1591, in
globals = debugger.run(setup['file'], None, None, is_module)
File "/opt/pycharm/helpers/pydev/pydevd.py", line 1018, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/opt/pycharm/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/matej/Desktop/camps_analysis/code/nextPin/server/spd/scripts/osm_and_camps/ppp.py", line 34, in
rule1.view()
File "/usr/local/lib/python3.6/dist-packages/skfuzzy/control/rule.py", line 247, in view
ControlSystemVisualizer(self).view().show()
AttributeError: 'tuple' object has no attribute 'show'

Error in Rule View

Hello , I was trying to implement the example in Python hosted website. But it is showing me following errors, although , it is showing the image

File "/home/sezan92/anaconda2/lib/python2.7/site-packages/skfuzzy/control/rule.py", line 247, in view
ControlSystemVisualizer(self).view().show()

AttributeError: 'tuple' object has no attribute 'show'

Membership Gaussmf

Just something I wanted to remark:
The Gaussian membership function which I think should only get close towards 0 is actually getting 0.

Why piece-wise MF only accepts 3 points? (ABC)?

I'm a bit noob in Fuzzy logic, but reading the 61131-7 (http://www.fuzzytech.com/binaries/ieccd1.pdf) it looked like one could have a piecewise mf composed of indefinite points (as seen in the FCL example on page 52 ):

FUZZIFY humidity
TERM low := (30,1) (50,0);
TERM middle := (30,0) (50,1) (70,1) (80,0); 
TERM high := (70,0) (80,1);
END_FUZZIFY

The MF for middle should be built with this four terms... not sure if in this case another MF function can be used to represent this points, but shouldn't it be possible to allow the user to build a piecewise mf from this points?

Final RFC before 0.2: minor API tweaks

Up to the present, scikit-fuzzy has taken a NumPy-like approach: generally a functional interface, with essentially all functions brought into the base namespace.

Benefits: allows a simple structure where people just import skfuzzy as fuzz and everything is available. Drawbacks: becomes cluttered quickly, reducing accessibility.

We're at the point where clutter becomes a concern. Specifically for the new control system interface, I think this may not be the right model. It may be best to keep it in skfuzzy.control. This allows all of the new functions to be grouped and more clearly linked. The downside is that users may not expect this, given the prior design, and have difficulty finding it.

I'm leaning toward keeping the new API objects in skfuzzy.control, out of the base namespace, but would appreciate other thoughts. Also, would people prefer

import skfuzzy as fuzz
import skfuzzy.control as control  # Only available with this import

control.Antecedent

vs

import skfuzzy as fuzz

fuzz.control.Antecedent  # available but not in base `fuzz` namespace

Why only 3,5,7 terms with automf? Easy modified automf...

I needed to use more than 7 terms auto generated with automf, and it was actually simply to modify the function:

  1. Delete the else that raises exception for a number other than 3,5, or 7
  2. Include following code before if Invert is True
if number > 7 :
        names = ['T1']
        for i in range(2,number+1):
            names.append('T'+str(i))

It worked like a charm for me.

Microsoft Visual C++ 2010 erro

hello sir first of all thank you for you quick and effective response with your help i am able to complete my robot. i am facing some other issue like Microsoft Visual C++ 2010 is missing and error for vcvarsall.bat is not found. please it is resist me from installing many other modules please reply with some permanent solution. thank yoou

Cannot use logical operators in consequent

Hi there,

In the documentation it is reported that it is possible to use negation in a consequent, but it seems that toolkit does not support it. It throws an assertion error.

Installation error in Beaglebone Black Debian 8.6

I want to install scikit fuzzy and get this error message

pip install -U scikit-fuzzy
....
```
`Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-UKRpkC/scipy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-NqAtte-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-UKRpkC/scipy/``

Any possibility for surface plotting as in Matlab?

Wondering whether there's any plans in this direction as I have not been able to find anything from searching around (or by introspection on the code). Would love to be proven wrong.

Otherwise, hacking together something along the lines of 'given this range of possible inputs, get defuzzified outputs for all of them and produce something plottable' should not be too hard. I wouldn't want to start trying unless its not already available though.

Ensure true division in all .py files

Reported as a sidenote in #115 was different behavior if floats were provided to fuzzy membership creation functions vs. integers.

There was at least one instance where this could happen, so in #116 from __future__ import division should fix the problem in generatemf.py.

This Issue serves as a reminder that the same motif should be added to every other Python source file in the repo, alongside absolute_import and print_function.

Discussion/RFC: Add Takagi-Sugeno-Kang (TSK, Sugeno) fuzzy systems

The new fuzzy system API (initially in #70, follow-ups in #76 and #92 so far) is designed for classical Mamdani fuzzy systems.

It has been requested that we consider adding support for TSK systems in the new framework.

This Issue is the place for discussion about potentially adding this support. Please post any thoughts about

  • How such a system would ideally work, from a user perspective. Pseudo-code appreciated.
  • Options that need to be exposed to the user, and at what levels
  • API concerns - can this be toggled in a Consequent object with a kwarg, or should it be a separate ConsequentTSK object.

Once we have a sense of the ideal design, we can move forward with implementation.

More elegant API for defining complex fuzzy rules

Some complex rules cannot be defined in the current framework. A minimal example is

IF var0['good'] AND (var1['bad'] OR var2['good']) THEN consequent['happy']

The issue is order of operations combined with user-defined groupings ().

One potential path forward would include overriding Python's __and__, and __or__ object methods for fuzzy variables. These would return a new CompositeVariable object which would track order of operations of multiple constituent fuzzy variables. Done properly, this would allow an elegant API like

rule1 = fuzz.control.FuzzyRule()
rule1.antecedents = var0['good'] & (var1['bad'] | var2['good'])
rule1.consequents = consequent['happy']

The current method of defining rules could be maintained, as it works well for simpler systems. However, the new API would be general enough to support nearly all use cases. We could simply move to the new API.

Comments welcome.

NameError: name 'version' is not defined

I installed as: pip install -U scikit-fuzzy.

When "import skfuzzy as fuzz" gives error:

NameError: name 'version' is not defined

My system: ubuntu 14.04 LTS; python2.7

Odd cluster center behavior in C-Means

From the mailing list, reported by Aiken Oliver:

I'm looking as using fuzzy cmeans in some projects, and particularly with data with a large number of clusters. As a first pass, I'm generating a number of blobs using make_blobs out of sklearn.datasets:

X, y = make_blobs(n_samples=5000,
                  n_features=8,
                  centers=25,
                  cluster_std=2,
                  center_box=(-100.0, 100.0),
                  shuffle=True)

centers, clusters, _, _, _, _, _ = fuzz.cmeans(X.T, 25, 2, 0.0005, 2000)

Passing the resulting blobs to cmeans for clustering results appears to work when 15 or fewer centers and 8 features. Increasing the number of features or centers by more than a few causes many or all of the cmeans centers to all converge to overlapping points. This seems to occur whether the increase is to the number of features or centers -- either will cause this convergence. I didn't see a discussion of this in the papers on fcm I've looked through, but was wondering if this was a behavior of the algorithm that is expected. Perhaps it can be overcome by careful selection of the initial partition matrix? But I've not been able to do so this far...

AttributeError: 'module' object has no attribute 'Antecedent'

When execute the script /docs/examples/plot_tipping_problem_newapi.py, appear the error message:

Traceback (most recent call last):
File "./PESQUISAS/AGRICULTURA/scripts/fuzzy.py", line 52, in
quality = fuzz.Antecedent(np.arange(0, 11, 1), 'quality')
AttributeError: 'module' object has no attribute 'Antecedent'

Implementation of alpha cuts

Within this package is there a way to perform alpha cuts on a given membership function? I.e. a way to get the bounds of the universe x that occur at the intersection of the membership function for a given degree of membership?

I've been exploring the package but can't seem to find anything. Hoping to integrate some of the work done here into some optimization algorithms elsewhere.

Colors of all clusters are uniform

When I run the example 'Fuzzy c-means clustering' in the first step I get three color dots (orange, green and blue), but in the next steps all dots are blue(((

Memory error applying an FIS to rasters

I have 2 different classes that are used to read in raster datasets and then create an output raster dataset where each pixel is calculated using an FIS created with a control system. The 2 input class runs fine, but the 3 input runs into a memory error. They're not huge rasters (2600 x 4500, 45MB), and i set cache=False in the ControlSystemSimulation. Attached is where the error comes up.
memory_error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.