Exemplo n.º 1
0
 def color(self):
     max_color=0
     dict_colors={0:"Red",1:"Orange",2:"Blue"}            
     out_color = self.defuzzification()
     r = FuzzySet(Trapezoidal(0,0,self.red,self.orange))
     o = FuzzySet(Trapezoidal(self.red,self.orange,self.orange+self.delta,self.blue))
     b = FuzzySet(Trapezoidal(self.orange+self.delta,self.blue,1,1))
     mv_colors =[r.calculate_membership(out_color),
                 o.calculate_membership(out_color),
                 b.calculate_membership(out_color)]
     arg_max = np.argmax(mv_colors)
     max_color = dict_colors[arg_max]
     return max_color
Exemplo n.º 2
0
    def ext_temp(self):
        """ MF for the exteriors temperature"""
        gs.global_uod = (0, 1)
        mv_temp = []

        low_temp = FuzzySet(Trapezoidal(0, 0, 10 / 50, 20 / 50))
        med_temp = FuzzySet(Trapezoidal(10 / 50, 20 / 50, 25 / 50, 30 / 50))
        high_temp = FuzzySet(Trapezoidal(20 / 50, 30 / 50, 50 / 50, 50 / 50))

        mv_temp = [
            low_temp.calculate_membership(self.temp),
            med_temp.calculate_membership(self.temp),
            high_temp.calculate_membership(self.temp)
        ]

        return mv_temp
Exemplo n.º 3
0
    def medicine(self):
        """ MF for: % of times the patient has taken its medicine"""
        gs.global_uod = (0, 1)
        mv_medicine = []

        low_m = FuzzySet(Trapezoidal(0, 0, .2, .3))
        med_m = FuzzySet(Trapezoidal(.2, .3, .5, .6))
        high_m = FuzzySet(Trapezoidal(.5, .6, 1, 1))

        mv_medicine = [
            low_m.calculate_membership(self.med),
            med_m.calculate_membership(self.med),
            high_m.calculate_membership(self.med)
        ]

        return mv_medicine
Exemplo n.º 4
0
    def visits(self):
        """ MF for pyhsical visits from family members or friends per week"""
        gs.global_uod = (0, 1)
        mv_visits = []

        low_v = FuzzySet(Trapezoidal(0, 0, 2 / 30, 5 / 30))
        med_v = FuzzySet(Trapezoidal(3 / 30, 7 / 30, 7 / 30, 14 / 30))
        high_v = FuzzySet(Trapezoidal(7 / 30, 14 / 30, 30 / 30, 30 / 30))

        mv_visits = [
            low_v.calculate_membership(self.num_visits),
            med_v.calculate_membership(self.num_visits),
            high_v.calculate_membership(self.num_visits)
        ]

        return mv_visits
Exemplo n.º 5
0
    def family_int(self):
        """ MF for family interactions via the device and SM per week"""
        gs.global_uod = (0, 1)

        mv_fam_int = []

        low_fam_int = FuzzySet(Trapezoidal(0, 0, 2 / 30, 5 / 30))
        med_fam_int = FuzzySet(Trapezoidal(3 / 30, 7 / 30, 7 / 30, 14 / 30))
        high_fam_int = FuzzySet(Trapezoidal(7 / 30, 14 / 30, 30 / 30, 30 / 30))

        mv_fam_int = [
            low_fam_int.calculate_membership(self.familyint),
            med_fam_int.calculate_membership(self.familyint),
            high_fam_int.calculate_membership(self.familyint)
        ]

        return mv_fam_int
Exemplo n.º 6
0
    def mind_exercise(self):
        """ MF for daily time using mind games per week"""
        gs.global_uod = (0, 1)
        mv_mind_exercise = []

        low_m_ex = FuzzySet(Trapezoidal(0, 0, 15 / 120, 20 / 120))
        med_m_ex = FuzzySet(Trapezoidal(15 / 120, 15 / 120, 30 / 120,
                                        60 / 120))
        high_m_ex = FuzzySet(
            Trapezoidal(30 / 120, 60 / 120, 120 / 120, 120 / 120))

        mv_mind_exercise = [
            low_m_ex.calculate_membership(self.m_exercise),
            med_m_ex.calculate_membership(self.m_exercise),
            high_m_ex.calculate_membership(self.m_exercise)
        ]

        return mv_mind_exercise
Exemplo n.º 7
0
    def phys_exercise(self):
        """ MF for the physical exercise of the patient"""
        gs.global_uod = (0, 1)

        mv_p_exercise = []

        low_p_exercise = FuzzySet(Trapezoidal(0, 0, 15 / 120, 20 / 120))
        med_p_exercise = FuzzySet(
            Trapezoidal(15 / 120, 15 / 120, 30 / 120, 60 / 120))
        high_p_exercise = FuzzySet(
            Trapezoidal(30 / 120, 60 / 120, 120 / 120, 120 / 120))

        mv_p_exercise = [
            low_p_exercise.calculate_membership(self.p_exercise),
            med_p_exercise.calculate_membership(self.p_exercise),
            high_p_exercise.calculate_membership(self.p_exercise)
        ]

        return mv_p_exercise
Exemplo n.º 8
0
from fuzzycreator.membership_functions.gaussian import Gaussian
from fuzzycreator.fuzzy_sets.fuzzy_set import FuzzySet
from fuzzycreator import visualisations
from fuzzycreator import global_settings as gs
from fuzzycreator.measures import entropy_t1
from fuzzycreator.measures import inclusion_t1
from fuzzycreator.measures import compatibility_t1


gs.global_uod = (0, 1)
A = FuzzySet(Gaussian(0.5, 0.05))
B = FuzzySet(Gaussian(0.5, 0.12))
C = FuzzySet(Gaussian(0.5, 0.23))

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

print('Entropy:')
print(entropy_t1.kosko(A))
print(entropy_t1.kosko(B))
print(entropy_t1.kosko(C))

print('Inclusion:')
print(inclusion_t1.sanchez(A, B))
print(inclusion_t1.sanchez(A, C))
print(inclusion_t1.sanchez(B, C))

print('Compatibility:')
print(compatibility_t1.compatibility(A, B))
print(compatibility_t1.compatibility(B, C))
print(compatibility_t1.compatibility(A, C))
Exemplo n.º 9
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))
Exemplo n.º 10
0
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))

# A.plot_set()
# B.plot_set()
# C.plot_set()

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

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

visualisations.plot_sets((A, B, C))
Exemplo n.º 11
0
from fuzzycreator.membership_functions.trapezoidal import Trapezoidal
from fuzzycreator.membership_functions.gaussian import Gaussian
from fuzzycreator.fuzzy_sets.fuzzy_set import FuzzySet

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))