I am currently doing a fuzzy inference system project in Python, however, a question came up. I have to do it the hard way, that is, do it step by step, as done here: https://pythonhosted.org/scikit-fuzzy/auto_examples/plot_tipping_problem.html. When we define the rules we use IF-THEN rules which I suppose is an implication (a->b = ~a OR b). However, on this website they do the following;
For the rules:
If the food is bad OR the service is poor, then the tip will be low
If the service is acceptable, then the tip will be medium
If the food is great OR the service is amazing, then the tip will be high.
```python # Now we take our rules and apply them. Rule 1 concerns bad food OR service. # The OR operator means we take the maximum of these two. active_rule1 = np.fmax(qual_level_lo, serv_level_lo) # Now we apply this by clipping the top off the corresponding output # membership function with `np.fmin` tip_activation_lo = np.fmin(active_rule1, tip_lo) # removed entirely to 0 # For rule 2 we connect acceptable service to medium tipping tip_activation_md = np.fmin(serv_level_md, tip_md) # For rule 3 we connect high service OR high food with high tipping active_rule3 = np.fmax(qual_level_hi, serv_level_hi) tip_activation_hi = np.fmin(active_rule3, tip_hi) tip0 = np.zeros_like(x_tip) ```
This code gives the result it is supposed to. However, the line where they compute "
active_rule" doesn't make sense to me, because they are doing "
np.min" which is not an implication. I tried replacing it with "
np.fmax(~a,b)" but the defuzzification result gives wrong.
Any idea how to know if they are actually making an implication or not?
Thank you in advance
maxbecause if one of the conditions is high enough, the result is high enough. Given this equivalation, the equivalent of
minbecause if one of the conditions is not high enough, the result should not be high enough.
1-x. Personally, I would not use
orbut instead write the formula from the start (not based on binary logic) as an equation that take all inputs into account, as having both inputs high might indicate a better result than having one high which is better than neither high. $\endgroup$
x nand y = not x or not y,
x nor y = not x and not y$\endgroup$