Refatoração dos códigos para padronizar com a rfts - Ismail & Efendi
This commit is contained in:
parent
aa7389e228
commit
81f98d81e1
@ -31,30 +31,31 @@ class ImprovedWeightedFTS(fts.FTS):
|
|||||||
def __init__(self,name):
|
def __init__(self,name):
|
||||||
super(ImprovedWeightedFTS, self).__init__(1,name)
|
super(ImprovedWeightedFTS, self).__init__(1,name)
|
||||||
|
|
||||||
def forecast(self,data):
|
def generateFLRG(self, flrs):
|
||||||
actual = self.fuzzy(data)
|
flrgs = {}
|
||||||
if actual["fuzzyset"] not in self.flrgs:
|
for flr in flrs:
|
||||||
return self.sets[actual["fuzzyset"]].centroid
|
if flr.LHS in flrgs:
|
||||||
flrg = self.flrgs[actual["fuzzyset"]]
|
flrgs[flr.LHS].append(flr.RHS)
|
||||||
mi = np.array([self.sets[s].centroid for s in flrg.RHS.keys()])
|
else:
|
||||||
return mi.dot( flrg.weights() )
|
flrgs[flr.LHS] = ImprovedWeightedFLRG(flr.LHS);
|
||||||
|
flrgs[flr.LHS].append(flr.RHS)
|
||||||
|
return (flrgs)
|
||||||
|
|
||||||
def train(self, data, sets):
|
def train(self, data, sets):
|
||||||
last = {"fuzzyset":"", "membership":0.0}
|
self.sets = sets
|
||||||
actual = {"fuzzyset":"", "membership":0.0}
|
tmpdata = common.fuzzySeries(data,sets)
|
||||||
|
flrs = common.generateRecurrentFLRs(tmpdata)
|
||||||
|
self.flrgs = self.generateFLRG(flrs)
|
||||||
|
|
||||||
for s in sets:
|
def forecast(self,data):
|
||||||
self.sets[s.name] = s
|
mv = common.fuzzyInstance(data, self.sets)
|
||||||
|
|
||||||
self.flrgs = {}
|
actual = self.sets[ np.argwhere( mv == max(mv) )[0,0] ]
|
||||||
count = 1
|
|
||||||
for inst in data:
|
|
||||||
actual = self.fuzzy(inst)
|
|
||||||
|
|
||||||
if count > self.order:
|
if actual.name not in self.flrgs:
|
||||||
if last["fuzzyset"] not in self.flrgs:
|
return actual.centroid
|
||||||
self.flrgs[last["fuzzyset"]] = ImprovedWeightedFLRG(last["fuzzyset"])
|
|
||||||
|
|
||||||
self.flrgs[last["fuzzyset"]].append(actual["fuzzyset"])
|
flrg = self.flrgs[actual.name]
|
||||||
count = count + 1
|
|
||||||
last = actual
|
mi = np.array([self.sets[s].centroid for s in flrg.RHS.keys()])
|
||||||
|
return mi.dot( flrg.weights() )
|
||||||
|
Loading…
Reference in New Issue
Block a user