I have the following three rules

  1. If A is medium and B is low then quality is low
  2. If A is medium and B is medium then quality is medium
  3. If A is medium and B is high then quality is medium

With this link as reference https://pythonhosted.org/scikit-fuzzy/auto_examples/plot_tipping_problem.html and the code

# We need the activation of our fuzzy membership functions at these values.
# The exact values 6.5 and 9.8 do not exist on our universes...
# This is what fuzz.interp_membership exists for!
qual_level_lo = fuzz.interp_membership(x_qual, qual_lo, 6.5)
qual_level_md = fuzz.interp_membership(x_qual, qual_md, 6.5)
qual_level_hi = fuzz.interp_membership(x_qual, qual_hi, 6.5)

serv_level_lo = fuzz.interp_membership(x_serv, serv_lo, 9.8)
serv_level_md = fuzz.interp_membership(x_serv, serv_md, 9.8)
serv_level_hi = fuzz.interp_membership(x_serv, serv_hi, 9.8)

# 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

How do I write the same kind of rules for AND operator with respect to my rule?

  • 1
    $\begingroup$ Hi and welcome to AI SE! This seems to be just a programming issue, so your post is off-topic here. See ai.stackexchange.com/help/on-topic for more details. You have also asked your question on Stack Overflow: https://stackoverflow.com/q/61560097/3924118, which is probably the best place to ask this question anyway. $\endgroup$ – nbro May 3 '20 at 20:27
  • $\begingroup$ Definitely come back an visit us with questions involving fuzzy logic from a theoretical standpoint! $\endgroup$ – DukeZhou May 3 '20 at 23:14

Browse other questions tagged or ask your own question.