Skip to content

Incorrect plotting in FuzzySystem plot_surface method #30

Open
@guilherme-marcello

Description

Hello there,

It seems there is a bug in the plot_surface method of the FuzzySystem class that results in an incorrect surface plot.

In order to make the problem more evident, I changed slightly the code example provided in https://github.com/aresio/simpful/blob/master/examples/example_output_surface.py . The following code reproduces the issue:

from simpful import *
import matplotlib.pylab as plt
from numpy import linspace, array

FS = FuzzySystem()

S_1 = FuzzySet(function=Triangular_MF(a=0, b=0, c=5), term="poor")
S_2 = FuzzySet(function=Triangular_MF(a=0, b=5, c=10), term="good")
S_3 = FuzzySet(function=Triangular_MF(a=5, b=10, c=10), term="excellent")
lvarS = LinguisticVariable([S_1, S_2, S_3], concept="Service quality", universe_of_discourse=[0,10])
FS.add_linguistic_variable("Service", lvarS)

F_1 = FuzzySet(function=Triangular_MF(a=0, b=0, c=10), term="rancid")
F_2 = FuzzySet(function=Triangular_MF(a=0, b=10, c=10), term="delicious")
lvarF = LinguisticVariable([F_1, F_2], concept="Food quality", universe_of_discourse=[0,10])
FS.add_linguistic_variable("Food", lvarF)

T_1 = FuzzySet(function=Triangular_MF(a=0, b=0, c=10), term="small")
T_2 = FuzzySet(function=Triangular_MF(a=0, b=10, c=20), term="average")
T_3 = FuzzySet(function=Trapezoidal_MF(a=10, b=20, c=25, d=25), term="generous")
lvarT = LinguisticVariable([T_1, T_2, T_3], universe_of_discourse=[0,25])
FS.add_linguistic_variable("Tip", lvarT)

R1 = "IF (Service IS excellent) THEN (Tip IS generous)"
FS.add_rules([R1])

fig = FS.plot_surface(variables=['Service', 'Food'], output='Tip', detail=5)

The relevant change here is that a single rule "IF (Service IS excellent) THEN (Tip IS generous)" was added to the fuzzy system.

Observed output: The resulting plot (image bellow) incorrectly suggests that the tip increases with food quality instead of service quality.

Figure_1

The version of the packages I used in this execution:

  • simpful 2.12.0
  • numpy 1.26.4
  • scipy 1.12.0
  • matplotlib 3.8.3

I also replicated the issue with the following versions:

  • simpful 2.12.0
  • numpy 1.26.4
  • scipy 1.13.1
  • matplotlib 3.7.1

Is this really an unexpected behavior?

Thanks.
Guilherme.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions