Hi Michael,
I got the IndexError: tuple index out of range when calling manual forecast() for rnn. Below are the details:
Error
IndexError Traceback (most recent call last)
Cell In[18], line 2
1 f.set_estimator('rnn')
----> 2 f.manual_forecast(
3 lags = 24,
4 layers_struct=[
5 ('LSTM',{'units':10,'activation':'tanh'}),
6 ('LSTM',{'units':10,'activation':'tanh'}),
7 ('LSTM',{'units':10,'activation':'tanh'}),
8 ],
9 optimizer = 'Adam',
10 epochs = 15,
11 plot_loss = True,
12 validation_split=0.2,
13 call_me = 'rnn_tanh_activation',
14 )
735 self.call_me = self.estimator if call_me is None else call_me
737 if test_again and self.test_length > 0 and self.estimator != 'combo':
--> 738 self.test(
739 **kwargs,
740 dynamic_testing=dynamic_testing,
741 call_me=call_me,
742 )
743 elif bank_history:
744 if self.call_me not in self.history.keys():
1319 f1.eval_cis(False)
1320 f1.actuals = actuals
-> 1321 f1.manual_forecast(
1322 dynamic_testing = dynamic_testing,
1323 test_again = False,
1324 call_me = call_me,
1325 **kwargs,
1326 )
1327 fcst = f1.forecast
1329 if not already_existed:
744 if self.call_me not in self.history.keys():
745 self.history[self.call_me] = {}
747 preds = (
748 self._forecast_sklearn(
749 fcster=self.estimator,
750 dynamic_testing=dynamic_testing,
751 **kwargs,
752 )
753 if self.estimator in self.sklearn_estimators
--> 754 else getattr(self, f"forecast{self.estimator}")(
755 dynamic_testing=dynamic_testing, **kwargs
756 )
757 )
758 self.forecast = preds
759 if bank_history:
12 with warnings.catch_warnings(record=True) as warn_list:
13 warnings.simplefilter("always")
---> 14 result = func(*args, **kwargs)
15 for warn in warn_list:
16 logging.warning(warn.message)
978 X = X.reshape(X.shape[0], X.shape[1], 1)
979 fut = fut.reshape(fut.shape[0], fut.shape[1], 1)
--> 980 model = get_compiled_model(y)
981 hist = model.fit(X, y, **kwargs)
982 fcst = model.predict(fut)
850 kv[1]["return_sequences"] = (
851 layers_struct[i + 1][0] != "Dense"
852 )
854 model.add(layer(**kv[1]))
--> 855 model.add(Dense(y.shape[1])) # output layer
857 # compile model
858 model.compile(optimizer=local_optimizer, loss=loss)
IndexError: tuple index out of range
Code:
f.set_estimator('rnn')
f.manual_forecast(
lags = 24,
layers_struct=[
('LSTM',{'units':10,'activation':'tanh'}),
('LSTM',{'units':10,'activation':'tanh'}),
('LSTM',{'units':10,'activation':'tanh'}),
],
optimizer = 'Adam',
epochs = 15,
plot_loss = True,
validation_split=0.2,
call_me = 'rnn_tanh_activation',
)
Code from:
https://towardsdatascience.com/stacking-time-series-models-to-improve-accuracy-7977c6667d29
Could you please help? Thank you so much!
Thank you,
Lily