Improvements on EnsembleFTS.forecast_distribution_ahead
This commit is contained in:
parent
60785ac89f
commit
839842d61f
@ -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.models import chen, cheng, hofts, hwang, ismailefendi, sadaei, song, yu
|
||||||
from pyFTS.probabilistic import ProbabilityDistribution
|
from pyFTS.probabilistic import ProbabilityDistribution
|
||||||
import scipy.stats as st
|
import scipy.stats as st
|
||||||
|
from itertools import product
|
||||||
|
|
||||||
|
|
||||||
def sampler(data, quantiles):
|
def sampler(data, quantiles):
|
||||||
@ -69,6 +70,10 @@ class EnsembleFTS(fts.FTS):
|
|||||||
elif model.original_max > self.original_max:
|
elif model.original_max > self.original_max:
|
||||||
self.original_max = model.original_max
|
self.original_max = model.original_max
|
||||||
|
|
||||||
|
|
||||||
|
def get_UoD(self):
|
||||||
|
return [self.original_min, self.original_max]
|
||||||
|
|
||||||
def train(self, data, **kwargs):
|
def train(self, data, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -252,10 +257,11 @@ class EnsembleFTS(fts.FTS):
|
|||||||
|
|
||||||
uod = self.get_UoD()
|
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):
|
for k in np.arange(self.order, steps+self.order):
|
||||||
forecasts = []
|
forecasts = []
|
||||||
|
'''
|
||||||
lags = {}
|
lags = {}
|
||||||
for i in np.arange(0, self.order): lags[i] = sample[k-self.order]
|
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():
|
for p in root.paths():
|
||||||
path = list(reversed(list(filter(None.__ne__, p))))
|
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))
|
forecasts.extend(self.get_models_forecasts(path))
|
||||||
|
|
||||||
sample.append(sampler(forecasts, np.arange(0.1, 1, 0.1)))
|
sample.append(sampler(forecasts, np.arange(0.1, 1, 0.1)))
|
||||||
|
@ -21,15 +21,15 @@ data = TAIEX.get_data()
|
|||||||
model = ensemble.EnsembleFTS()
|
model = ensemble.EnsembleFTS()
|
||||||
|
|
||||||
for k in [15, 25, 35]:
|
for k in [15, 25, 35]:
|
||||||
for order in [1, 2]:
|
for order in [1, 2, 3]:
|
||||||
fs = Grid.GridPartitioner(data=data, npart=k)
|
fs = Grid.GridPartitioner(data=data, npart=k)
|
||||||
tmp = hofts.WeightedHighOrderFTS(partitioner=fs)
|
tmp = hofts.WeightedHighOrderFTS(partitioner=fs, order=order)
|
||||||
|
|
||||||
tmp.fit(data)
|
tmp.fit(data)
|
||||||
|
|
||||||
model.append_model(tmp)
|
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
|
from pyFTS.benchmarks import benchmarks as bchmk
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user