## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
Josh Warner
@JDWarner
The differences should be in the realm of floating point error.
There may be minor inherent differences in Matlab versus Scikit-Fuzzy, if rounding is involved, because MATLAB rounds incorrectly. Specifically, MATLAB always rounds 0.5 up. IEEE correct rounding behavior - which is what Python and more importantly NumPy follow - round to the nearest even number to minimize systematic error when rounding. So Scikit-Fuzzy will round 0.5 down to 0 (nearest even int).
Max Feinberg
@mxfeinberg
@JDWarner Thank you for the reply! I realized that the discrepancies were actually due to differences in membership functions. Scikit-Fuzzy is a great library and I appreciate all the work you've done.
Josh Warner
@JDWarner
Marceliwut
@Marceliwut

Hello,
I must say that i love your work! This library is simple to use, but also can fulfill most of the needs!
The only question i have is how to accomodate more than 2 statements in a rules? np.fmin and np.fmax can take only two arrays as arguments i would need three.
I am creating fuzzy apartment search engine for my university. So basically i need rules like - "IF Apartment price is in given range AND apartment size is bit low AND apartment room number is too low THEN apartment score is MEDIUM" -this one is only an example.

Any ideas for such thing? :)

Thanks!

Josh Warner
@JDWarner
Hi @Marceliwut - I think you're going to be pleasantly surprised. The tipping project example only creates Rules which relate two Antecedents... but the actual underlying infrastructure supports an arbitrary combination using binary logic.
So you would make a rule like (making up variable names) ctrl.Rule(price['medium'] & size['low'] & number['low'], score['medium']) and it should work just great!
When everything is AND connected, you don't need to concern yourself with order of operations. However, order of operations is supported via parentheticals when combining various Antecedent Terms via a complex Rule when you may want to mix OR with AND.
Give it a shot, I think that should meet your needs.
Marceliwut
@Marceliwut
Hey @JDWarner -I have actually ended up using "the hard way" with nested fmin and fmax functions. Anyway thanks for your reply and most of all thanks for your work on this library. If you ever come to Cracow I owe you some sightseeing tour with local and beers. Thank you!
godmind Smith
@godmind_gitlab
Hello Everybody. Want to know whether there is a way to have fuzzy Singleton membership function with scikit-fuzzy? Best regards.
godmind Smith
@godmind_gitlab
I have already checked scikit-fuzzy membership sub-package, but don't see anything like that.
Josh Warner
@JDWarner
The underlying assumptions made in Scikit-Fuzzy assume your membership functions are sparsely defined, but represent an underlying continuous distribution.
There is not a special case to perfectly represent a delta function, which I think is what you are asking about. However, you should be able to very well approximate this behavior.
Based on the datatype of the underlying universe variable, define a membership function with zero at both ends, 1 at the intended singleton value, and 0 at the singleton value ±eps for the variable datatype.
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
@godmind_gitlab
hexiangdong2017
@hexiangdong2017
I'm new to skfuzzy and have a question. How to combine Rules with "AND" logic?
LakshanVio
@lakshanVio
Is there any way to develop a fuzzy type 2 inference system?
nl
Hi Everybody. I want to convert Fuzzy sets to an intuitionistic fuzzy set. How can do it in python?
Josh Warner
@JDWarner
@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
@JDWarner
@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.
dnlwgnd
@dnlwgnd
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
@JDWarner
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.
dnlwgnd
@dnlwgnd
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
@misc{https://doi.org/10.5281/zenodo.3541384,
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},
}
Mao Qiangqiang
@maoqiangqiang
hello,
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
@maoqiangqiang
@JDWarner
could you tell me how to modify the plot of ('fuzzyVariable.view(sim = 'sys')')
Josh Warner
@JDWarner
@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
@maoqiangqiang

@JDWarner
Dear,

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.

@JDWarner
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"
nDreCoelho
@nDreCoelho

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
@BenConstable9
Hello,
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
@WinstonDodson
Dr. Warner - thanks for the great work. Question re: FPC - any sources describing it more fully?
Winston Dodson
@WinstonDodson
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
@jensbremnes_gitlab
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
@snehalvartak
Hello, I need some help with the skfuzzy. COuld someone tell me how to get the fuzzy value of consequent before defuzzification?
Dmitriy Ogureckiy
@my000own000files1
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
@my000own000files1
is this library compatible with the Python Control Systems Library ?
bayan-kabbani
@bayan-kabbani

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])

x_Recency.view()
x_Frequency.view()
x_Monetary.view()

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..
regards