From c559c1050deafbae53da0cab707950c4bf90c289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=C3=B4nio=20C=C3=A2ndido?= Date: Wed, 27 Feb 2019 11:00:41 -0300 Subject: [PATCH] Bugfix on IncrementalEnsembleFTS --- pyFTS/models/ensemble/ensemble.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyFTS/models/ensemble/ensemble.py b/pyFTS/models/ensemble/ensemble.py index 9bb8bf1..18e6636 100644 --- a/pyFTS/models/ensemble/ensemble.py +++ b/pyFTS/models/ensemble/ensemble.py @@ -46,9 +46,6 @@ class EnsembleFTS(fts.FTS): """The method used to mix the several model's forecasts into a unique point forecast. Options: mean, median, quantile, exponential""" self.interval_method = kwargs.get('interval_method', 'quantile') """The method used to mix the several model's forecasts into a interval forecast. Options: quantile, extremum, normal""" - #self.order = 1 - self.exp_factor = kwargs.get('exp_factor', 0.5) - """Multiplicative factor on exponential averaging of the models""" def append_model(self, model): """ @@ -105,7 +102,10 @@ class EnsembleFTS(fts.FTS): l = len(self.models) if l == 1: return forecasts[0] - ret = np.nansum([np.exp(-(self.exp_factor * (l - k))) * forecasts[k] for k in range(l)]) + w = [np.exp(-(l - k)) for k in range(l)] + sw = sum(w) + w = w / sw + ret = np.nansum([w[k] * forecasts[k] for k in range(l)]) return ret