from decimal import Decimal
from fuzzycreator.fuzzy_sets.discrete_t1_fuzzy_set import DiscreteT1FuzzySet
from fuzzycreator.measures import similarity_t1
from fuzzycreator import visualisations

A_points = {1: Decimal('0.25'), 2: 1, 3: Decimal('0.25')}
B_points = {2: Decimal('0.33'), 3: Decimal('0.66'), 4: Decimal('0.33')}
A = DiscreteT1FuzzySet(A_points)
B = DiscreteT1FuzzySet(B_points)

visualisations.plot_sets((A, B))

print(A.calculate_membership(1))
print(A.calculate_alpha_cut(Decimal('0.25')))
print(A.calculate_centroid())

print('s(A, B) =', similarity_t1.jaccard(A, B))
Пример #2
0
from decimal import Decimal
from fuzzycreator.membership_functions.triangular import Triangular
from fuzzycreator.membership_functions.trapezoidal import Trapezoidal
from fuzzycreator.membership_functions.gaussian import Gaussian
from fuzzycreator.fuzzy_sets.fuzzy_set import FuzzySet

from fuzzycreator.measures import similarity_t1
from fuzzycreator.measures import distance_t1

from fuzzycreator import global_settings as gs
from fuzzycreator import visualisations

A = FuzzySet(Triangular(0, 2, 4))
B = FuzzySet(Trapezoidal(3, 5, 7, 9))
C = FuzzySet(Gaussian(5, 1))

# calculations
print(A.calculate_membership(Decimal('3.5')))
print(A.calculate_alpha_cut(Decimal('0.5')))
print(A.calculate_centroid())

gs.global_x_disc = 101
print('s(B, C) =', similarity_t1.jaccard(B, C))

gs.global_alpha_disc = 20
print('d(A, C) =', distance_t1.chaudhuri_rosenfeld(B, C))

visualisations.plot_sets((A, B, C))