buguroo / pyknow

PyKnow: Expert Systems for Python
GNU Lesser General Public License v3.0
471 stars 141 forks source link

Enhancement: FuzzyPyKnow #6

Open Bazmundi opened 6 years ago

Bazmundi commented 6 years ago

Inline with fuzzyClips, fuzzy extensions to facts please.

nilp0inter commented 6 years ago

This is a desirable feature for a future release and is definitely in the long-term roadmap.

Because we are no experts in fuzzyClips we are open to know if you have any ideas on how to implement this. If you want to contribute with a pull request, please feel free to do so.

Angular-Angel commented 5 years ago

You can technically do it now, it's just a bit of a pain. Oh, and OR rules will ditch after the first success, even if there are other matches with relevant variables. See:

 @Rule(FuzzyFact(name="C", probability=MATCH.c), FuzzyFact(name="E", probability=MATCH.e))
    def fuzzy_rule_c_and_e_equals_f(self, c, e):
        self.declare(FuzzyFact(name="F", probability= c * e));

    def fuzzy_or(self, a, b):
        return a + b - a * b;

    @Rule(OR(FuzzyFact(name="E", probability=MATCH.e), FuzzyFact(name="F", probability=MATCH.f), FuzzyFact(name="G", probability=MATCH.g)))
    def fuzzy_rule_e_f_or_g_equals_f(self, e = 0, f = 0, g = 0):

        self.declare(FuzzyFact(name="H", probability= self.fuzzy_or(self.fuzzy_or(e, f), g)));