38 lines
747 B
Python
38 lines
747 B
Python
from pyFTS import *
|
|
|
|
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
|