From 5f7c0f0bfabfa6666eccaf567b8c94c232788176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=C3=B4nio=20C=C3=A2ndido=20de=20Lima=20e=20Silva?= Date: Tue, 9 May 2017 19:03:53 -0300 Subject: [PATCH] - Bugfixes in naive, arima and quantreg and optimizations on benchmarks --- benchmarks/arima.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/benchmarks/arima.py b/benchmarks/arima.py index f61f6f0..fce1705 100644 --- a/benchmarks/arima.py +++ b/benchmarks/arima.py @@ -35,7 +35,8 @@ class ARIMA(fts.FTS): try: self.model = stats_arima(data, order=(self.p, self.d, self.q)) self.model_fit = self.model.fit(disp=0) - except: + except Exception as ex: + print(ex) self.model_fit = None def ar(self, data): @@ -55,14 +56,14 @@ class ARIMA(fts.FTS): ret = [] if self.d == 0: - ar = np.array([self.ar(ndata[k - self.p: k]) for k in np.arange(self.p, l)]) + ar = np.array([self.ar(ndata[k - self.p: k]) for k in np.arange(self.p, l+1)]) #+1 to forecast one step ahead given all available lags else: - ar = np.array([ndata[k] + self.ar(ndata[k - self.p: k]) for k in np.arange(self.p, l)]) + ar = np.array([ndata[k] + self.ar(ndata[k - self.p: k]) for k in np.arange(self.p, l+1)]) if self.q > 0: residuals = np.array([ndata[k] - ar[k - self.p] for k in np.arange(self.p, l)]) - ma = np.array([self.ma(residuals[k - self.q: k]) for k in np.arange(self.q, len(residuals))]) + ma = np.array([self.ma(residuals[k - self.q: k]) for k in np.arange(self.q, len(residuals)+1)]) ret = ar[self.q:] + ma else: