aresio / simpful

A friendly python library for fuzzy logic reasoning
Academic Free License v3.0
130 stars 33 forks source link

Probabilistic or and Weighted Rule for Mamdani #16

Closed akdenizince closed 1 year ago

akdenizince commented 2 years ago

Greetings, My name is Akdeniz. I sent an email about the some additional codes that I have added to increase useability last week and you wanted me to create a pull request. This is the first time I open a pull request, so if there is an issue please let me know.

Thank you for your time and consideration.

sspola commented 2 years ago

Hi @akdenizince , thank you for your contribution. Could you share a minimal working example of the probor function and weighted Mamdani fuzzy system? If probor is used only as aggregation function, it can be simply passed as a pointer with the argument aggregation_function, when calling the Mamdani inference method. Regarding the weights, I do not exactly understand how they can work without modifying the parser, so an example would be helpful.

Thanks!

akdenizince commented 2 years ago

Hi @sspola, I could not add the .py extension file, so I am sending the code as a text file with the excel contains required paramters. This is the smallest module of our model, but it includes both weight and probor applications. Since we have this model both in the languages of Python and MATLAB, we are able to compare the results and they are the same even for the modules with many parameters. For probor case, I also did not like the way that I used for calling it, but -if you wish to add it- I am sure that you can integrate or call it in a more appropriate way. By the way, I might be confusing weights with the firing strengths when I write the comment or email, but I am sure that you will understand what I am trying to imply when you check the example code.

Best wishes, Akdeniz.

Example.txt data.xls

sspola commented 2 years ago

Hi @akdenizince

I rearranged things to be consistent with the rest of the code :) Now you can import the probor function from simpful, and pass it as a pointer via the aggregation_function argument. E.g.: FS.Mamdani_inference(["HIVulInd"], aggregation_function=probor)

I also restructured the handling of the weights to make it consistent to what was already implemented for Sugeno inference.

Could you try this out and check that everything is okay (compared to the Matlab version)? Thank you very much for your contribution!

akdenizince commented 2 years ago

Hi @sspola, I have checked the final results of main modules and final distributions from both of the models, and I am also sending them to you so that you can check. The results are the same and I did not undergo any problems. Btw, I really liked the rearrangements that you made :) Best wishes, Akdeniz.

image image

sspola commented 1 year ago

Hi @akdenizince ,

good to hear! Thanks to you for your valuable additions :)

I will push a new version of Simpful as soon as possible.