Mamdani and other Sugeno inference systems #88
Replies: 3 comments 1 reply
-
|
Hi! I'm glad you like it! It wasn't specifically designed for pattern recognition, but I did use parts of it for that purpose before. I admit I never heard of Sugeno-like fuzzy logic before, so I can't say for sure if it's possible what you imagine, but I can't see why not. The rules work with a dictionary, so it shouldn't be too hard to adapt and return arbitrary objects like functions instead. Can you give an example of what you have in mind? |
Beta Was this translation helpful? Give feedback.
-
|
Hi Anselm,
This link is an explaination of the inference systems Mamdani of
Sugeno
https://www.mathworks.com/help/fuzzy/types-of-fuzzy-inference-systems.html
Sugeno doesn't need a step of defuzzyfication and doesn't need only few
computing ressources. It has been designed for being embarqued for
process control in very small microcontrolers.
It's exactly what I need.
In fact, Sugeno can be considered as a Mamdani inference if consequents
are singletons.
With fuzzylogic, singleton is not a single point but a triangle. Then
the result of the inference is not the value of the singleton but can
produce intermediate values.
For instance, pattern-recognition can use a Domain of only integers the
corresponding Sets being only singletons.
Many thanks for your interest.
Jean
Le mercredi 17 septembre 2025 à 07:44 -0700, Anselm Kiefner a écrit :
Hi! I'm glad you like it! It wasn't specifically designed for pattern
recognition, but I did use parts of it for that purpose before. I
admit I never heard of Sugeno-like fuzzy logic before, so I can't say
for sure if it's possible what you imagine, but I can't see why not.
The rules work with a dictionary, so it shouldn't be too hard to
adapt and return arbitrary objects like functions instead. Can you
give an example of what you have in mind?
—
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].
You are receiving this because you authored the thread.Message ID:
<Python-Fuzzylogic/fuzzylogic/repo-
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Hi Anselm,
Using fuzzylogic as a base I've developped:
. somes domains with their fussy sets
. a method for an inference for pattern-recognition,:
a set of rules which mimics the dictionnary of rules of
fussylogic
IF xxxx AND xxxxx THEN (<symbol>, <credence>)
a dictionnary with <symbol> as key of conditions to decide is
the candidate category can be accepted.
<symbol> IF <minimal credence>
The second dictionnary act as an aggregator.
Follow the piece of corresponding code :
class FuzzyLogicEngine:
# From module fuzzylogic
#
def _domain_info(self, dic):
assert type(dic) is dict
# key of the Set whose membership is maximal
#
key = max(dic, key=dic.get)
# value of that maximal membership
#
val = dic[key]
return (str(key), val)
def _rules_builder(self, text_rules):
# a very simple parsing method
#
rules_set = {}
for rule in text_rules:
#
# rtx = 'IF <domaine> IS <fussy-
set> AND <domaine> IS <fussy-set> THEN <catégorie>'
#
rtx = rule.split()
premices = (rtx[1]+'.'+rtx[3], rtx[5]+'.'+rtx[7])
consequence = rtx[9]
rules_set[premices] = str(consequence)
return rules_set
def _activations_builder(self, text_rules):
# a very simple parsing method
#
activations_set = {}
for rule in text_rules:
#
# rtx = '<catégorie> AS <annotation> IF <credence> WITH <ac
tion>'
#
rtx = rule.split()
categorie = rtx[0] # category
annotation = rtx[2] # annotation
credence = rtx[4] # minimal credence
action = rtx[6] # action
activations_set[categorie] = {
'credence' : float(credence),
'annotation': annotation,
'action' : action
}
return activations_set
def __init__(self, cfg, prm):
self.energ_domain = prm.fle_energ_domain
self.energ_res = prm.fle_energ_res
self.energ_sets = prm.fle_energ_sets
self.freqy_domain = prm.fle_freqy_domain
self.freqy_res = prm.fle_freqy_res
self.freqy_sets = prm.fle_freqy_sets
# Domain "Energ"
#
self.Energ = Domain(
self.energ_domain[0],
self.energ_domain[1],
self.energ_domain[2],
res=self.energ_res
)
# Fuzzy-sets for "Energ"
#
self.Energ.low = sigmoid(
1.0,
self.energ_sets['low'][0],
self.energ_sets['low'][1]
)
self.Energ.hig = sigmoid(
1.0,
self.energ_sets['hig'][0],
self.energ_sets['hig'][1]
)
self.Energ.mid = ~(self.Energ.low | self.Energ.hig)
# Domain "Freqy"
#
self.Freqy = Domain(
self.freqy_domain[0],
self.freqy_domain[1],
self.freqy_domain[2],
res=self.freqy_res
)
# Fuzzy-sets for "Freqy"
#
self.Freqy.low = sigmoid(
1.0,
self.freqy_sets['low'][0],
self.freqy_sets['low'][1]
)
self.Freqy.hig = sigmoid(
1.0,
self.freqy_sets['hig'][0],
self.freqy_sets['hig'][1]
)
self.Freqy.mid = ~(self.Freqy.low | self.Freqy.hig)
# Building the rules
#
text_rules = prm.fle_categorization_rules
self.rules = self._rules_builder(text_rules)
# Building the set of the contitions for activation
#
text_activations = prm.fle_activation_conditions
self.activations = self._activations_builder(text_activations)
def domains(self):
return (self.Energ, self.Freqy)
# Fuzzyfication
#
def energ_info(self, vre):
return self._domain_info(self.Energ(vre))
def freqy_info(self, w):
return self._domain_info(self.Freqy(w))
# Inference
#
def inference(self, vre, w):
# Getting the key of the best result
# ... for the different domains
#
(ekey, eval) = self._domain_info(self.Energ(vre))
(fkey, fval) = self._domain_info(self.Freqy(w))
# Inference
#
try:
catkey = (str(ekey), str(fkey)) # key to search the can
didate category
categ = self.rules[catkey] # candidate category
credence = min(eval, fval) # Fuzzy "and" to get th
e credence
except:
# no candidate category in the categorization rules
#
categ = None
credence = 0
return (categ, credence)
# Validation of the result of the inference
#
def is_inference_validated(self, categ, credence):
if categ and (categ in self.activations) and (credence > self.a
ctivations[categ]['credence']):
return True
else:
return False
def get_annotation(self, categ):
return self.activations[categ]['annotation']
def get_action(self, categ):
return self.activations[categ]['action']
The main drawback in that implementation of the inference method is
that I have not really implement a Sugeno-like inference because I use
the function max() on the domain instead iterating on the dictionnary
to access at all the memberships of concern.
I am on digging more deep in the API of fuzzylogic.
It could be, surely, in fuzzylogic to be capable to choose the
inference method to use.
A parenthesis: I've experimented with :
- sci-kit-fuzzy : very complicated to use
- fuzzy-expert : is always in alpha state
fuzzylogic is, in comparaison, very great !
Jean
--
Jean DEMARTINI ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I'm discovering fuzzylogic module and very pleased with it. Obviously i've tried the example in the tutorial. All is OK.
But my objective is to use fuzzylogic to build a fuzzy pattern-recognition system. In that case, the consequent of a rule is better to be a crisp value (a number of a category for instance) associated with a a.k.a membership interpreted as a credence (in the Bayes logic meaning).
It seems that fuzzylogic is posed upon a Mamdani inference system well suited for control but not for patter recognition.
The tutorial is a very concise and i'm not sure if it is possible to build a Sugeno-like inference system that's to say to put a function as a consequent in a rule.
Its possible to use fuzzylogic to describe all the domains used. Its is also possible to define an inference system from ground base upon the evaluation of a domain from a value. But a full Sugeno( or others) could be more suitable.
Many thanks it somebody have an idea for that.
Beta Was this translation helpful? Give feedback.
All reactions