Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Josh Warner
    For all intents and purposes this is a delta function.
    There is no built-in function to do this, but it's pretty simple to build your own membership function in this way. If this is a more widely desired feature, it would be simple to automate the process and expose it; the only arguments would be the universe range and the singleton value.
    godmind Smith
    Thanks very much for the reply, appreciate your work.
    I'm new to skfuzzy and have a question. How to combine Rules with "AND" logic?
    Is there any way to develop a fuzzy type 2 inference system?
    Hi Everybody. I want to convert Fuzzy sets to an intuitionistic fuzzy set. How can do it in python?
    Josh Warner
    @hexiangdong2017 you do not combine Rules, you make new ones. Each Rule is unique and separate from all other Rules. Within each Rule, you can have multiple Antecedents combined with arbitrary boolean logic including AND.
    @lakshanVio Type-2 inference systems are not implemented in the elegant system building API presented through skfuzzy.control. However, many of the necessary pieces for working with Type-2 systems are exposed in the base namespace as general purpose functions in the toolkit. I suspect much of the low-level legwork is present, but this isn't part of my active work so I am not entirely certain what might need to be tweaked or generalized.
    Josh Warner
    @NillliiiiMl_twitter Intuitionistic fuzzy sets are not currently implemented in scikit-fuzzy. Some generalization of many functions would be required in order to work with them.
    Hello, I am struggling to understand how to saturate my output. How should I partition my output variable to be able to receive a crispt output
    on the boundaries of my universe_
    I tried to add membership functions that have a portion outside the universe, so that a defuzz might yield a value outside the universe that then can be clipped to the universe, but it did not work that way.
    Josh Warner
    Great question. What you're finding is a general feature of classical fuzzy systems. Basically the actual response will not span the universe, the actual range of responses from the system will be a smaller range. This is because when generating the crisp output, the most extreme membership values are combined and then functionally the centroid value is found. Because membership functions are not singletons/delta functions, the nonzero membership at values prior to the extrema of the universe will pull the maximum available value back from the edge.
    This is nonintuitive but guaranteed by the underlying math. The solution is not to extend the membership functions outside the output universe(s). Instead, one solution is to extend the output universe(s) and the membership functions with nonzero values at the extrema such that the centroid of the membership function now reaches the desired endpoint.
    indeed not intuitive, but inevitable from the math. I tried your suggestions and I can design it in a way to give values in the desired range and then manually clip it to my original universe. It is just a bit ugly to have to mess with the universe in such a way. Wouldn't it be easier to instead extend the membership outside the universe? Also does the parameter clip_to_bounds of ControlSystemSimulation play a role in this problem (since it yielded the same output for either True or False)?
    Liber Liver
    @JDWarner Hey. How to cite scikit-fuzzy?
    Liber Liver
    I found one example but I recommend you to add proper paper into your repository README
      doi = {10.5281/ZENODO.3541384},
      url = {https://zenodo.org/record/3541384},
      author = {Warner, Josh and Sexauer, Jason and {Scikit-Fuzzy} and {Twmeggs} and {Alexsavio} and {Aishwarya Unnikrishnan} and Castelão, Guilherme and Pontes, Felipe Arruda and Uelwer, Tobias and {Pd2f} and {Laurazh} and Batista, Fernando and {Alexbuy} and Broeck, Wouter Van Den and Song, William and Badger, The Gitter and Pérez, Roberto Abdelkader Martínez and Power, James F. and {Himanshu Mishra} and Trullols, Guillem Orellana and Hörteborn, Axel and {99991}},
      title = {scikit-fuzzy/scikit-fuzzy: Scikit-Fuzzy 0.4.2},
      publisher = {Zenodo},
      year = {2019},
      copyright = {Open Access}
    Mao Qiangqiang
    can anyone tell me the meaning of rule.view() which has shown a node graph? what is the physical meaning of the node and arrow in the graph?
    Mao Qiangqiang
    could you tell me how to modify the plot of ('fuzzyVariable.view(sim = 'sys')')
    Josh Warner
    @dnlwgnd Clip_to_bounds makes inputs which would be outside the universe range instead get interpreted as if they were at the appropriate end of the range. This is useful to avoid errors in certain situations where you may not have absolute confidence in the range of values you could see. This doesn't change the range of values the system can output. Extending the universe outside the range isn't really viable; mathematically there are too many assumptions.
    @liber_liver_twitter Yes right now Zenodo citing the package is the best way. This isn't ideal, the paper describing the package has been on the back burner for too long.
    @maoqiangqiang rule.view() shows the underlying NetworkX graph showing the connectivity defined by that Rule between Antecedent Terms, their Antecedents, Consequents, and their Terms.
    The plots thus created are Matlotlib objects (figure and axis) can be accessed for further customization via the method laid out in #273
    Mao Qiangqiang


    I am sorry to @you here. but i am have a question. I am first to use the ctrl system.
    tip['medium'] = fuzz.trimf(tip.universe, [0, 13, 25]) -> the fuzz.trimf should return an array of membership;

    but when i use the tip['medium'], it is a consequent. so how to get the membership value just from tip['medium']. if i print(tip['medium']), it did not return anything.

    Sorry to trouble you again.
    As doc v0.3 said, the tipping problem in a hard way, there is a plot of aggregated membership from the aggregation of rule1, rule2 and rule3. But if i use the new API ctrl system, how to plot the aggregated result?when i use tip.view(sim = sys), there is only one graph and the plot is not satisfied. how can i see the aggregated result just like the plot in the example of "tipping problem in a hard way"

    Hey everyone!

    Firstly, let me congratulate and thank the authors of this package as it looks like to be a great tool.

    Secondly, I'm here because I've encountered some problems while running it and would like to ask for your help with some questions regarding the cmeans and cmeans_predict functions:

    1. when inserting the data in the cmeans and cmeans_predict functions, does the last column have to be the target column?

    2. My objective is to classify in 0 and 1s, data with 27 columns (26 features + 1 targets) so I need 2 clusters with, if I'm not mistaken, centers with 27 coordinates. When I create the model with the training data, the function returns the variable cntr with a shape of (2,6224). Can you explain why does the function return these values?

    3. After obtaining this cntr variable and applying it to the cmeans_predict function, with test_data with the same number of columns, I get the following error:
      "XA and XB must have the same number of columns (i.e. feature dimension.)"
      Could you explain why does this happen?

    Thank you, again, for your work.

    Best Regards,

    Ben Constable
    Thank you for the great work on this package and the tool which looks to be really useful. I've spent some time searching for how to find out the degree of membership for all of the classes of an output. If I have a series of inputs and a set of outputs, how could I see the degree of membership for each of these?
    Winston Dodson
    Dr. Warner - thanks for the great work. Question re: FPC - any sources describing it more fully?
    Winston Dodson
    Dr. Warner - the request above was meant in the spirit of getting info re: the concept of FPC with as little effort on your part as possible thus, a request for a reference. My need is for an understanding of FPC similar to that commonly available for WCSS / inertia in regards to KMeans. Thanks ahead of time. PS. if you want to provide an overview with a suggestion of how to complete the explanation I am open to collaborating with you in developing a version to include in your documentation. Thanks.
    Jens Einar Bremnes
    Hi! I am a PhD student. In the next few days, I will use fuzzy logic to control an ROV under the polar sea ice (I will of course cite you guys!). But now Im running out of time! The current implementation is based entirely on skfuzzy.control, as written here (https://pythonhosted.org/scikit-fuzzy/auto_examples/plot_tipping_problem_newapi.html#example-plot-tipping-problem-newapi-py). However, I am not able to change the method for the composition of rules. In particular, I want to use max-product composition. By composition of rules, I mean how to compute the membership function of the output variable. Is there an easy way to do this, using the simple example above? Thanks. Best, Jens.
    Snehal Vartak
    Hello, I need some help with the skfuzzy. COuld someone tell me how to get the fuzzy value of consequent before defuzzification?
    1 reply
    Dmitriy Ogureckiy
    hello everyone, can anyone help me.
    I am using class Controlsystem and how I can change defuzzify_method after creating istance of ControlSystemSimulation object ?
    Dmitriy Ogureckiy
    is this library compatible with the Python Control Systems Library ?

    Hello everyone!

    I have a problem with Trapezoidal membership function generator:
    I have 3 input & 1 output:

    x_Recency = ctrl.Antecedent(np.arange(0, 2, 1),'x_Recency')
    x_Frequency =ctrl.Antecedent(np.arange(0, 2, 1),'x_Frequency')
    x_Monetary =ctrl.Antecedent(np.arange(0, 7000, 1),'x_Monetary')
    x_Score = ctrl.Consequent(np.arange(0,101, 1),'x_Score')

    x_Recency['old']= fuzz.trapmf(x_Recency.universe, [0 ,0, 0.5, 1])
    x_Recency['new']= fuzz.trapmf(x_Recency.universe, [0,0.5, 1,1])
    x_Frequency['rarely'] = fuzz.trapmf(x_Frequency.universe, [-1,-1,0, 0.55])
    x_Frequency['often'] = fuzz.trapmf(x_Frequency.universe, [0,0.55, 1, 1])
    x_Monetary['low'] = fuzz.trapmf(x_Monetary.universe, [0,0, 873.5,7000])
    x_Monetary['high'] = fuzz.trapmf(x_Monetary.universe, [873.5, 6000, 7000,7000])

    the x_Recency,x_Frequency inputs doesn't appeare with form Trapezoidal like x_Monetary.
    I think the reason is the small range [0,1]... any ideas to change the parameter abcd for fuzz.trapmf..

    Jalil Nourisa
    Hi, i need to construct a fuzzy logic controller and run it in a loop. I tried a basic form of it using scikit-fuzzy and experience a memory leak. I took the example from the website and just ruuning in the loop. Pls kindly help in finding out what is the source of memory leak. Thanks
    from skfuzzy import control as ctrl
    from pympler import muppy,tracker
    import skfuzzy as fuzz
    import numpy as np
    import sys
    def base_example():
        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')
        tip['low'] = fuzz.trimf(tip.universe, [0, 0, 13])
        tip['medium'] = fuzz.trimf(tip.universe, [0, 13, 25])
        tip['high'] = fuzz.trimf(tip.universe, [13, 25, 25])
        rule1 = ctrl.Rule(quality['poor'] | service['poor'], tip['low'])
        rule2 = ctrl.Rule(service['average'], tip['medium'])
        rule3 = ctrl.Rule(service['good'] | quality['good'], tip['high'])
        tipping_ctrl = ctrl.ControlSystem([rule1, rule2, rule3])
        tipping = ctrl.ControlSystemSimulation(tipping_ctrl)
        tipping.input['quality'] = 6.5
        tipping.input['service'] = 9.8
    if __name__ == '__main__':
        tr = tracker.SummaryTracker() # to show the initial list of objects
        for i in range(100000):
            if i%500==0: # we monitor different in the list of objects every 500 iterations
                print('Iteration ',i)
                tr.print_diff() # to show the difference beween this iteration and the base one
    in the above example, i expect that one the execution of base_example() function is completed, the used memory is freed. But, it doesnt happen
    Hello Guys
    Anybody can help me? I am doing research on Intelligent traffic control using fuzzy logic using fuzzy toolkit (skfuzzy). I developed membership functions and rules. However, I can't test the performance of fuzzy inference delay time of car during departure.
    Hello, is there a way to extract the membership values of the output fuzzy sets after inference instead of getting the defuzzified value?
    Hello, amazing library, may be can help to someone the example that I prepare for my class, about to buy a house
    Anyone know if there are examples to use this library with images, like imṕrove the quality of the image?
    Hello, is there a library of firmware of scikit-fuzzy in micropython? I will be programming Fuzzy Logic in RPi Pico.
    Can someone tell me how to extract fuzzy rules that apply to class data?
    Hello! I would like to know if there is a way to generate rules set automatically. I have 5 antecedents and 1 consequent.
    Currently I have just written a script to generate the rules, but wanted to know if there is a better way to do it.
    Wang-Mendel algorithm?
    Dmitriy Ogureckiy
    Hi, if someone wanted to interface scikit-fuzzy with python control system library, you can try use my example
    Hello everybody.
    multiplier someone has an example or knows how to implement so that you can transfer several input values from a file csv?
    Juan Carlos Ragel
    hi, do you know if its possible to create a singleton membership function with this package?