Improvements on EnsembleFTS.forecast_distribution_ahead

This commit is contained in:
Petrônio Cândido 2019-05-28 17:06:24 -03:00
parent 60785ac89f
commit 839842d61f
2 changed files with 16 additions and 4 deletions

View File

@ -13,6 +13,7 @@ from pyFTS.common import SortedCollection, fts, tree
from pyFTS.models import chen, cheng, hofts, hwang, ismailefendi, sadaei, song, yu
from pyFTS.probabilistic import ProbabilityDistribution
import scipy.stats as st
from itertools import product
def sampler(data, quantiles):
@ -69,6 +70,10 @@ class EnsembleFTS(fts.FTS):
elif model.original_max > self.original_max:
self.original_max = model.original_max
def get_UoD(self):
return [self.original_min, self.original_max]
def train(self, data, **kwargs):
pass
@ -252,10 +257,11 @@ class EnsembleFTS(fts.FTS):
uod = self.get_UoD()
sample = data[start - self.order: start]
sample = [[k] for k in data[start - self.order: start]]
for k in np.arange(self.order, steps+self.order):
forecasts = []
'''
lags = {}
for i in np.arange(0, self.order): lags[i] = sample[k-self.order]
@ -267,7 +273,13 @@ class EnsembleFTS(fts.FTS):
for p in root.paths():
path = list(reversed(list(filter(None.__ne__, p))))
'''
lags = []
for i in np.arange(0, self.order):
lags.append(sample[k - self.order])
# Trace the possible paths
for path in product(*lags):
forecasts.extend(self.get_models_forecasts(path))
sample.append(sampler(forecasts, np.arange(0.1, 1, 0.1)))

View File

@ -21,15 +21,15 @@ data = TAIEX.get_data()
model = ensemble.EnsembleFTS()
for k in [15, 25, 35]:
for order in [1, 2]:
for order in [1, 2, 3]:
fs = Grid.GridPartitioner(data=data, npart=k)
tmp = hofts.WeightedHighOrderFTS(partitioner=fs)
tmp = hofts.WeightedHighOrderFTS(partitioner=fs, order=order)
tmp.fit(data)
model.append_model(tmp)
forecasts = model.predict(data, type='interval', method='quantile', alpha=.05)
forecasts = model.predict(data, type='distribution', smooth='histogram', steps_ahead=10)
from pyFTS.benchmarks import benchmarks as bchmk