def fuzzy_fitness(fitness): r = redis rate_by_fuzzy=[] fuzzy=[] activity = Activity_stream() print "FITNESS" print fitness for u in fitness: if u != "DefaultContext": usr, usr_date = u.split(":") exp = int(activity.experience(usr)) print ":P:P:P:P:P:P:P:P:" print exp rate = int(fitness[u]) print str(rate) +" , " + str(exp) #print fisuser(rate,exp) rate_by_fuzzy.append(rate * fisuser(rate,exp)) fuzzy.append(fisuser(rate,exp)) #print rate_by_fuzzy #print sum(rate_by_fuzzy) #print fuzzy #print sum(fuzzy) fuzzy_ponderation = sum(rate_by_fuzzy)/sum(fuzzy) return fuzzy_ponderation
def fuzzy_fitness(fitness): r = redis rate_by_fuzzy=[] fuzzy=[] activity = Activity_stream() print "FITNESS" print fitness for u in fitness: if u != "DefaultContext": usr, usr_date = u.split(":") #exp = int(r.get(usr)) exp = int(activity.experience(usr)) print ":P:P:P:P:P:P:P:P:" print exp rate = int(fitness[u]) n = Person() participation = n.get_participation(usr) participation = participation[0][0] ranking=get_level(participation) print str(rate) +" , " + str(exp) +" , " + str(ranking) print "PPPPPPPFUZZYPPPPP" print ranking print fisuser(rate, exp, ranking) rate_by_fuzzy.append(rate * fisuser(rate, exp, ranking)) fuzzy.append(fisuser(rate,exp,ranking)) print rate_by_fuzzy print sum(rate_by_fuzzy) print fuzzy print sum(fuzzy) fuzzy_ponderation = sum(rate_by_fuzzy)/sum(fuzzy) print fuzzy_ponderation return fuzzy_ponderation