From 4b8b0243d7b88e32b35f97c3f8e7845357b66ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=C3=B4nio=20C=C3=A2ndido?= Date: Thu, 21 Mar 2019 17:08:59 -0300 Subject: [PATCH] Bugfix in ensemble.Ensemble --- pyFTS/models/ensemble/ensemble.py | 4 ++++ pyFTS/tests/ensemble.py | 30 +++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/pyFTS/models/ensemble/ensemble.py b/pyFTS/models/ensemble/ensemble.py index 9aa5393..ea72920 100644 --- a/pyFTS/models/ensemble/ensemble.py +++ b/pyFTS/models/ensemble/ensemble.py @@ -64,6 +64,10 @@ class EnsembleFTS(fts.FTS): if model.has_seasonality: self.has_seasonality = True + if model.original_min < self.original_min: + self.original_min = model.original_min + elif model.original_max > self.original_max: + self.original_max = model.original_max def train(self, data, **kwargs): pass diff --git a/pyFTS/tests/ensemble.py b/pyFTS/tests/ensemble.py index fa2d5ff..89651ae 100644 --- a/pyFTS/tests/ensemble.py +++ b/pyFTS/tests/ensemble.py @@ -12,6 +12,34 @@ from pyFTS.models.incremental import IncrementalEnsemble, TimeVariant from pyFTS.data import AirPassengers, artificial +from pyFTS.models.ensemble import ensemble +from pyFTS.models import hofts +from pyFTS.data import TAIEX + +data = TAIEX.get_data() + +model = ensemble.EnsembleFTS() + +for k in [15, 25, 35]: + for order in [1, 2]: + fs = Grid.GridPartitioner(data=data, npart=k) + tmp = hofts.WeightedHighOrderFTS(partitioner=fs) + + tmp.fit(data) + + model.append_model(tmp) + +forecasts = model.predict(data, type='interval', method='quantile', alpha=.05) + +from pyFTS.benchmarks import benchmarks as bchmk + +#f, ax = plt.subplots(1, 1, figsize=[20, 5]) + +#ax.plot(data) +#bchmk.plot_interval(ax, forecasts, 3, "") +print(forecasts) + +''' mu_local = 5 sigma_local = 0.25 mu_drift = 10 @@ -33,7 +61,7 @@ model2 = IncrementalEnsemble.IncrementalEnsembleFTS(partitioner_method=Grid.Grid forecasts = model2.predict(signal) print(forecasts) - +''' ''' passengers = np.array(passengers["Passengers"])