pyFTS/fts.py

36 lines
726 B
Python
Raw Normal View History

class FTS:
def __init__(self,order,name):
self.sets = {}
self.flrgs = {}
self.order = order
self.name = name
def fuzzy(self,data):
best = {"fuzzyset":"", "membership":0.0}
for f in self.sets:
fset = self.sets[f]
if best["membership"] <= fset.membership(data):
best["fuzzyset"] = fset.name
best["membership"] = fset.membership(data)
return best
def defuzzy(self,data):
pass
def learn(self, data, sets):
pass
def predict(self,data):
return self.defuzzy(data)
def predictDiff(self,data,t):
return data[t] + self.defuzzy(data[t-1]-data[t])
def __str__(self):
tmp = self.name + ":\n"
for r in self.flrgs.keys():
tmp = tmp + str(self.flrgs[r]) + "\n"
return tmp