from fuzzycreator.measures import distance_it2 from fuzzycreator import global_settings as gs from fuzzycreator import visualisations gs.global_uod = (0, 20) gs.global_x_disc = 201 A = IntervalT2FuzzySet(Triangular(0, 2, 4), Triangular(1, 2, 3, 0.8)) B = IntervalT2FuzzySet(Trapezoidal(2, 4, 7, 9), Trapezoidal(3, 5, 6, 8, 0.8)) C = IntervalT2FuzzySet(Gaussian(13, 1), Gaussian(13, 0.5, 0.8)) D = IntervalT2FuzzySet(Gaussian(15, 1), Gaussian(16, 1)) print(A.calculate_membership(Decimal('0.5'))) print(A.calculate_alpha_cut_upper(Decimal('0.5'))) print(A.calculate_alpha_cut_lower(Decimal('0.5'))) print(A.calculate_centre_of_sets()) print(A.calculate_overall_centre_of_sets()) visualisations.plot_sets((A, B, C, D)) print('s(A, B) =', similarity_it2.jaccard(A, B)) print('s(C, D) =', similarity_it2.jaccard(C, D)) print('d(A, B) =', distance_it2.mcculloch(A, B)) print('d(B, A) =', distance_it2.mcculloch(B, A)) print('d(C, D) =', distance_it2.mcculloch(C, D)) print('d(D, C) =', distance_it2.mcculloch(D, C))
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))
def create_fuzzy_set_from_data(d): """Plot fuzzy sets generated from data given by load_data().""" fuzzy_sets = [generate_fuzzy_sets.generate_polling_t1_fuzzy_set(d)] visualisations.plot_sets(fuzzy_sets)
from fuzzycreator.fuzzy_sets.interval_t2_fuzzy_set import IntervalT2FuzzySet from fuzzycreator.fuzzy_sets.general_t2_fuzzy_set import GeneralT2FuzzySet from fuzzycreator.measures import similarity_t1 from fuzzycreator.measures import distance_t1 from fuzzycreator import global_settings as gs from fuzzycreator import visualisations gs.global_uod = (0, 10) A = FuzzySet(Triangular(0, 2, 4)) B = FuzzySet(Trapezoidal(3, 5, 7, 9)) C = FuzzySet(Gaussian(10, 1)) visualisations.plot_sets((A, B, C)) gs.global_uod = (0, 15) visualisations.plot_sets((A, B, C)) C.uod = [0, 15] visualisations.plot_sets((A, B, C)) gs.global_uod = (0, 10) C.uod = (0, 10) gs.global_x_disc = 11 print('global_x_disc = 11:') print('\ts(B, C) =', similarity_t1.jaccard(B, C)) print('\tCentroid of C =', C.calculate_centroid()) gs.global_x_disc = 101 print('global_x_disc = 101:')