Git Product home page Git Product logo

esrnn_torch's People

Contributors

azulgarza avatar cchallu avatar kdgutier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esrnn_torch's Issues

target between negative and positive

Hi,
I have data with wide range between huge negative and positive values. each ID has different of range. some of them fall between very wide range and some of them are not. it mentioned that the procedure don't accept negative values. how to configure my data properly in order to fit with this application ? do I need to do min max scaler ? if yes, do I scale individual series or all series ? or do you have other suggestions ?

thank you

Input for OWA Calculation - AttributeError

Hi,

I was searching for OWA implementations to use the measure in one of my projects. I'm starting with calculation for a single time series. The ESRNN lib provides this function:

final_owa, final_mase, final_smape = evaluate_prediction_owa(y_hat_df, y_train_df, X_test_df, y_test_df, naive2_seasonality=1)

When I look at the code (https://github.com/kdgutier/esrnn_torch/blob/master/ESRNN/utils_evaluation.py#L370-L400), X_test_df is not used at all in the function - is that correct?

Also, I'm not sure about the input format for using the function.

Here is my input for y_train_df, which contains the historical target values:

unique_id ds y
00010_000030_BS824_2018-01-01 2017-12-01 1497400.0
00010_000030_BS824_2018-01-01 2017-11-01 1707420.0
00010_000030_BS824_2018-01-01 2017-10-01 1989485.0
00010_000030_BS824_2018-01-01 2017-09-01 1697800.0
00010_000030_BS824_2018-01-01 2017-08-01 1574400.0
00010_000030_BS824_2018-01-01 2017-07-01 1260556.0
00010_000030_BS824_2018-01-01 2017-06-01 1319198.0
00010_000030_BS824_2018-01-01 2017-05-01 1592793.0
00010_000030_BS824_2018-01-01 2017-04-01 1575775.0
00010_000030_BS824_2018-01-01 2017-03-01 1808200.0
00010_000030_BS824_2018-01-01 2017-02-01 1365519.0
00010_000030_BS824_2018-01-01 2017-01-01 1904000.0
00010_000030_BS824_2018-01-01 2016-12-01 1713520.0
00010_000030_BS824_2018-01-01 2016-11-01 1908281.0
00010_000030_BS824_2018-01-01 2016-10-01 1737900.0
00010_000030_BS824_2018-01-01 2016-09-01 2005440.0
00010_000030_BS824_2018-01-01 2016-08-01 1683500.0
00010_000030_BS824_2018-01-01 2016-07-01 1179682.0
00010_000030_BS824_2018-01-01 2016-06-01 1834500.0
00010_000030_BS824_2018-01-01 2016-05-01 1949500.0
00010_000030_BS824_2018-01-01 2016-04-01 1811450.0
00010_000030_BS824_2018-01-01 2016-03-01 2001200.0
00010_000030_BS824_2018-01-01 2016-02-01 1273837.0

Here is the y_hat_df, which contains my model predictions for the future values:

 unique_id ds y_hat
00010_000030_BS824_2018-01-01 2018-01-01 1403634.0
00010_000030_BS824_2018-01-01 2018-02-01 1543464.0
00010_000030_BS824_2018-01-01 2018-03-01 1751357.0
00010_000030_BS824_2018-01-01 2018-04-01 1874214.0
00010_000030_BS824_2018-01-01 2018-05-01 1810092.0
00010_000030_BS824_2018-01-01 2018-06-01 1811571.0
00010_000030_BS824_2018-01-01 2018-07-01 1828860.0
00010_000030_BS824_2018-01-01 2018-08-01 1708163.0
00010_000030_BS824_2018-01-01 2018-09-01 1672521.0
00010_000030_BS824_2018-01-01 2018-10-01 1809456.0
00010_000030_BS824_2018-01-01 2018-11-01 1870753.0
00010_000030_BS824_2018-01-01 2018-12-01 1596886.0
00010_000030_BS824_2018-01-01 2019-01-01 1253630.0
00010_000030_BS824_2018-01-01 2019-02-01 1618861.0
00010_000030_BS824_2018-01-01 2019-03-01 1466855.0
00010_000030_BS824_2018-01-01 2019-04-01 1677125.0
00010_000030_BS824_2018-01-01 2019-05-01 1887335.0
00010_000030_BS824_2018-01-01 2019-06-01 1576052.0

And finally, here is my y_test_df, which contains the true future values with the same dates as in y_hat_df:

unique_id ds y
00010_000030_BS824_2018-01-01 2018-01-01 2237400.0
00010_000030_BS824_2018-01-01 2018-02-01 1967330.0
00010_000030_BS824_2018-01-01 2018-03-01 1886660.0
00010_000030_BS824_2018-01-01 2018-04-01 1818600.0
00010_000030_BS824_2018-01-01 2018-05-01 2060476.0
00010_000030_BS824_2018-01-01 2018-06-01 1928000.0
00010_000030_BS824_2018-01-01 2018-07-01 1506416.0
00010_000030_BS824_2018-01-01 2018-08-01 1705200.0
00010_000030_BS824_2018-01-01 2018-09-01 1602600.0
00010_000030_BS824_2018-01-01 2018-10-01 2002980.0
00010_000030_BS824_2018-01-01 2018-11-01 1829730.0
00010_000030_BS824_2018-01-01 2018-12-01 1385800.0
00010_000030_BS824_2018-01-01 2019-01-01 1923362.0
00010_000030_BS824_2018-01-01 2019-02-01 1849415.0
00010_000030_BS824_2018-01-01 2019-03-01 1921600.0
00010_000030_BS824_2018-01-01 2019-04-01 2143900.0
00010_000030_BS824_2018-01-01 2019-05-01 2014900.0
00010_000030_BS824_2018-01-01 2019-06-01 1832100.0

Upon calling evaluate_prediction_owa I get, on this line: y_hat_id = y_hat_panel[top_row:bottom_row].y_hat.to_numpy() the following error - any idea why that happens? What am I missing?

AttributeError Traceback (most recent call last)
~/projects/semco/semicon-forecast/src/a4_benchmark.py in
----> 1 evaluate_prediction_owa(y_hat_df, y_train_df,
2 None, y_test_df,
3 naive2_seasonality=12)
4

~/miniconda3/envs/semicon/lib/python3.8/site-packages/ESRNN/utils_evaluation.py in evaluate_prediction_owa(y_hat_df, y_train_df, X_test_df, y_test_df, naive2_seasonality)
390 y_insample = y_train_df.filter(['unique_id', 'ds', 'y'])
391
--> 392 model_owa, model_mase, model_smape = owa(y_panel, y_hat_panel,
393 y_naive2_panel, y_insample,
394 seasonality=naive2_seasonality)

~/miniconda3/envs/semicon/lib/python3.8/site-packages/ESRNN/utils_evaluation.py in owa(y_panel, y_hat_panel, y_naive2_panel, y_insample, seasonality)
350 total_mase = evaluate_panel(y_panel, y_hat_panel, mase,
351 y_insample, seasonality)
--> 352 total_mase_naive2 = evaluate_panel(y_panel, y_naive2_panel, mase,
353 y_insample, seasonality)
354 total_smape = evaluate_panel(y_panel, y_hat_panel, smape)

~/miniconda3/envs/semicon/lib/python3.8/site-packages/ESRNN/utils_evaluation.py in evaluate_panel(y_panel, y_hat_panel, metric, y_insample, seasonality)
316 top_row = np.asscalar(y_hat_panel['unique_id'].searchsorted(u_id, 'left'))
317 bottom_row = np.asscalar(y_hat_panel['unique_id'].searchsorted(u_id, 'right'))
--> 318 y_hat_id = y_hat_panel[top_row:bottom_row].y_hat.to_numpy()
319 assert len(y_id)==len(y_hat_id)
320

~/miniconda3/envs/semicon/lib/python3.8/site-packages/pandas/core/generic.py in getattr(self, name)
5463 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5464 return self[name]
-> 5465 return object.getattribute(self, name)
5466
5467 def setattr(self, name: str, value) -> None:

AttributeError: 'DataFrame' object has no attribute 'y_hat'

Saving Model

How do you save the model if you want to use it to make predictions later?

About the algorithm setting and the dataframe structure

Hi,
Our team project is trying to use this algorithm to do the time series forecasting, and we set up the algorithm as shown on the Readme page. But it still don't work, can you take a look at our dataframe and see if we misunderstood what you mean? Thanks!

about exogenous variable

Hi, I would like to try for my own dataset. I have some questions regarding exogenous variable.
does the method allow multiple exogenous variable ? does the method use future exogenous variable to predict future target ? If yes, how to configure my dataset for my case where exogenous variable is not available for forecasting?

thank you

Posible bug

assert not np.isnan(batch_y).any(), \

Revisando el OF me encontré que la función de pérdida está generando nans, aún no encuentro bien qué lo hace pero hasta donde veo este assert es el que debería impedir que haya batches con nan (si hay batches con nan, la pérdida se vuelve nan). Debería quitarse el not, no?

Monthly M3 Implementation of ESRNN

Hi there,

Thanks a lot for the great implementation. I am trying to fit the monthly M3 data, but the model does not seem to be training. My data looks as follows:

image

image

image

image

Note that the y_hat_naive2 is in fact just the simple naive.

When, I fit the model, I get the following:

image

In an earlier issue, it has been mentioned that it could possibly be a mismatch in forecasting horizon, but after playing around with it, I don't see any improvement. Below, you can find a link to the colab notebook so you can reproduce it.

https://colab.research.google.com/drive/1rFz5SskOqKuaxn3ijZUJwIPBqDGy7AK1?usp=sharing

Thanks a lot!

Simon

How to set seasonality

Hi, by default seasonality is set to []. my data is daily data and have multiple seasonality : weekly and every six months. how to put in the model ? would you mind explaining the help function below
seasonality: int list
list of seasonalities of the time series
Hourly [24, 168], Daily [7], Weekly [52], Monthly [12],
Quarterly [4], Yearly []

why for daily sesonality is 7 , weekly 52, etc ?

thanks

application for time series data with trend

Hi, I am trying to use this package for air passenger dataset the result as follow :
image

is it good to use this package for this typical dataset (with seasonal and trend) ?

my model is look like this :
model = ESRNN(max_epochs=250, freq_of_test=5, batch_size=1, learning_rate=1e-3, per_series_lr_multip=0.8, lr_scheduler_step_size=10, lr_decay=0.1, gradient_clipping_threshold=50, rnn_weight_decay=0.0, level_variability_penalty=100, testing_percentile=0, training_percentile=100, ensemble=False, max_periods=25, seasonality=[12], input_size=12, output_size=40, cell_type='LSTM', state_hsize=40, dilations=[[1], [6]], add_nl_layer=False, random_seed=1, device='cuda')

Is there any advice to tune the model in order to get good result ?

thank you

how to use continuous exogenous variable in the future for forecasting problem

Hi,
I need to forecast a target variable and I have two time series variable as continuous exog variables that can be used to forecast target series for multistep ahead. I can access the future values of exog variable and for production purpose I would like to simulate the impact of exog variable in the future to the forecasted target. So, I need to use exog at time t+1 to forecast target at time t+1 and so on. can I do that?

thank you

About the Naive2 function

Hi there,
Are you able to show an example about how to use Naive2 prediction ( The class you have for ESRNN). I am wondering what is the h in the predict function. Since I am trying to input an array, but it doesn't seem to work. Thanks!

hyperparameter tuning

Hi there,
I am just wondering, how do you decide the input size, output size, frequen_of_test and batch size. Since using the M4 data, if I change the input and output, it will give me NaN for the evaluation matrices.

Example of use of the 'unique_id' and 'x' variables.

Hi,

When forecasting multiple Time-series at a time, I was wondering whats the mechanics between the "unique_id" and "x" category feeded to the ESRNN ?

Does the model learns each Time series independently of each others by unique_id and learns interactions between Time series with same unique_id and different "x" categories values ?

Can we use the "x" to learn hierarchies ? For example if we decompose the same Time serie into 3 others Time series (for example using 3 different data filters), the unique_id is the same for the 3 (same original Time series) but different categories (filter1, filter2, filter3), soo each dates are multiplied 3 Times here for the same unique_id, one by category.

Whats is the mechanics here ?

Thanks!

Traning and testing losses return 'nan' during training

Hi all,

First of all thank you for your amazing job on ES-RNN pytorch implementation.
I have been able to run the M4 scripts, but I encountered troubles trying to run ESRNN architecture on an another data source.

I am trying to apply this model on the M5 competition. The input is the following tables:
image

I define the model as following (taking some parameters from the initial config dict) and use previously defined tables to train it:
image

But I observe that the network does not seem to learn, because of 'nan' returned during training. Is there something I missed ?

how to check fitting performance

is there any way to check whether the model is overfit visually ? need advice to avoid overfit model using this repo.

thank you

Data Formatting for ES-RNN

@kdgutier
Suppose I want to train the ES-RNN on stock dataset. But because the stock market closes, I do not have data for the weekends. Would it be okay even if I have gaps in the dates for weekends and possibly some public holidays?

NAN for evaluation metrics

Hi there,

I am running into a similar problem as reported in a previous issue. While I do get a value for training loss and testing loss, I get a nan for my evaluation metrics: sMAPE, MASE and OWA, when I am fitting the model. The response below is when I am fitting the model with weekly data:

Infered frequency: W-SUN
=============== Training ESRNN ===============

========= Epoch 0 finished =========
Training time: 12.04543
Training loss (50 prc): 0.49441
Testing loss (50 prc): 0.02670
OWA: nan
SMAPE: nan
MASE: nan

I have checked and there are no zeroes in the first ds. What could be causing the problem?

Applying ES-RNN to sub hourly data

Hello,

thanks for making this awesome implementation open-source. 💯
I know that the M4 competition data only deals with data which is at minimum hourly data.
Is it possible to use the algorithm for minutely data? Im a bit confused right now regarding the config.
thanks a lot !

Very short time series in unbalanced panel, assert n_windows>0

Hey, I am getting the following error. Do you think you can help? Thanks in advance!

model.fit(X_df, y_df)
Infered frequency: D
=============== Training ESRNN ===============

Traceback (most recent call last):

File "", line 1, in
model.fit(X_df, y_df)

File "C:\Users\diogo\AppData\Roaming\Python\Python37\site-packages\ESRNN\ESRNN.py", line 368, in fit
warm_start=warm_start, shuffle=shuffle, verbose=verbose)

File "C:\Users\diogo\AppData\Roaming\Python\Python37\site-packages\ESRNN\ESRNN.py", line 186, in train
windows_y, windows_y_hat, levels = self.esrnn(batch)

File "C:\Users\diogo\AppData\Roaming\Python\Python37\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)

File "C:\Users\diogo\AppData\Roaming\Python\Python37\site-packages\ESRNN\utils\ESRNN.py", line 273, in forward
windows_y_hat, windows_y, levels, seasonalities = self.es(ts_object)

File "C:\Users\diogo\AppData\Roaming\Python\Python37\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)

File "C:\Users\diogo\AppData\Roaming\Python\Python37\site-packages\ESRNN\utils\ESRNN.py", line 54, in forward
assert n_windows>0

AssertionError

problem with pandas

Hello.
When i used: y_hat_df = model.predict(X_test_df) i get the next issue:
ValueError: You are trying to merge on object and datetime64[ns] columns. If you wish to proceed you should use pd.concat
So, i tried to downgrade pandas to 0.25.2 and the issue remains.
I can not either run the example for training and use model.fit(X_train_df, y_train_df) instead.
Can I modify the ESRNN.py and replace the merge with another sequence?

I'm sorry for my english and thanks

input format of training and test data

Hey,

after running the example successfully, I am trying to feed in custom data.
My feature dataset consists of many time series, of which I would only like to predict a few. The data has a frequency of 5s. All time series are non-negative, but many contain zeros. The time series that I would like to predict are all strictly larger zero.

(i) How would one adapt the code to work with 5s data? I was thinking of a quick fix to simply replace the 5s dates by daily dates? But I would still have to remove the influence of daily seasonality from the model, right?

(ii) Also, when trying to predict on just a subset of the time series by inscribing just those into the y_df, I get an assertion error in line 135 of data.py:

assert batch_y.shape[1]>=1 

(iii) I added +1 to the training and test data to prevent having zero values. Would that be ok?

I don't know whether the discussion here is still ongoing, but I would appreciate any feedback!

Best,
JC

Prediction interval for ES-RNN

Thank you for making this implementation available. Sorry if I missed It; Is there an easy way to obtain prediction intervals with your ES-RNN implementation?

Allow for more covariates / features

Thanks for making the model available!

Right now, as I see it, the RNN part of the model allows for one feature only. Would it be possible for you to extend the architecture to allow for an arbitrary number of features?

Many thanks!

Exogenous variables

Is it possible to set more than one exogenous variable? From what I understood, only the column 'x' of the 'X_df' dataframe can contain an exogenous variable.

Thanks

Return NaN prediction

Hi There! I got Nan prediction. I have monthly dataset and would like to forecast 12 steps ahead (1 year). This is my dataset :
image

this is validation that fed into training as well
image

this is the model and training :
model = ESRNN(max_epochs=20, freq_of_test=5, batch_size=5, learning_rate=1e-1, per_series_lr_multip=0.8, lr_scheduler_step_size=10, lr_decay=0.1, gradient_clipping_threshold=50, rnn_weight_decay=0.0, level_variability_penalty=100, testing_percentile=10, training_percentile=90, ensemble=True, max_periods=25, seasonality=[], input_size=2, output_size=12,frequency=None, cell_type='LSTM', state_hsize=40, dilations=[[1], [6]], add_nl_layer=False, random_seed=1, device='cpu')

model.fit(training[['unique_id','ds','x']], training[['unique_id','ds','y']],validation[['unique_id','ds','x']],validation[['unique_id','ds','y','y_hat_naive2']],y_hat_benchmark='y_hat_naive2')

I got nan and undetected freq as shown by this during training:
image

predict return Nan values:
image

Hourly results typo in the results table in readme?

I noticed your implementation performs similar / better than the original implementation of smyl in all cases, but hourly data. In the table "current results", it is stated 0.615 vs 0.92. Could it be 0.915, instead? Otherwise, do you have an explanation for where that huge difference in performance comes from?
Best, JC

Error during training, from input_size, output_size and time span incompatibility

Hi,
I am trying to train my own dataset. the data is monthly basis with end of months as the timestamp (ds). the procedure also require y_hat_benchmark if I use test dataframe. below is the error :

`Infered frequency: M
=============== Training ESRNN ===============


AssertionError Traceback (most recent call last)
in
1 model.fit(train[['unique_id','ds','x']], train[['unique_id','ds','y']],
----> 2 test[['unique_id','ds','x']], test[['unique_id','ds','y','y_hat_naive_1']],y_hat_benchmark='y_hat_naive_1')

~\Anaconda3\envs\nlp\lib\site-packages\ESRNN\ESRNN.py in fit(self, X_df, y_df, X_test_df, y_test_df, y_hat_benchmark, warm_start, shuffle, verbose)
366 self._fitted = True
367 self.train(dataloader=self.train_dataloader, max_epochs=self.mc.max_epochs,
--> 368 warm_start=warm_start, shuffle=shuffle, verbose=verbose)
369
370 def instantiate_esrnn(self, exogenous_size, n_series):

~\Anaconda3\envs\nlp\lib\site-packages\ESRNN\ESRNN.py in train(self, dataloader, max_epochs, warm_start, shuffle, verbose)
184
185 batch = dataloader.get_batch()
--> 186 windows_y, windows_y_hat, levels = self.esrnn(batch)
187
188 # Pinball loss on normalized values

~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs)
548 result = self._slow_forward(*input, **kwargs)
549 else:
--> 550 result = self.forward(*input, **kwargs)
551 for hook in self._forward_hooks.values():
552 hook_result = hook(self, input, result)

~\Anaconda3\envs\nlp\lib\site-packages\ESRNN\utils\ESRNN.py in forward(self, ts_object)
271 def forward(self, ts_object):
272 # ES Forward
--> 273 windows_y_hat, windows_y, levels, seasonalities = self.es(ts_object)
274
275 # RNN Forward

~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs)
548 result = self._slow_forward(*input, **kwargs)
549 else:
--> 550 result = self.forward(*input, **kwargs)
551 for hook in self._forward_hooks.values():
552 hook_result = hook(self, input, result)

~\Anaconda3\envs\nlp\lib\site-packages\ESRNN\utils\ESRNN.py in forward(self, ts_object)
52 windows_range = range(windows_start, windows_end)
53 n_windows = len(windows_range)
---> 54 assert n_windows>0
55
56 # Initialize windows, levels and seasonalities

AssertionError:`

I have some question about the input and output

Hi there,
So I am now using a time series data which only have two columns- Date and Price. So I am wondering if I can use this algorithm in this situation, and let the algorithm train the model only on price, and predict the price in the future. In other words,
I am wondering if this model can separate my data automatically, so that I will not need to separate by "lag" myself. Thank you for your help!

M4 starting dates not defined

Hello
I thank you very much for this implementation of ES-RNN in python. Very good job!!
It seems to me that all the time-series start at the same date 1970/01/01 and not at the StartingDate indicated by M4-info.csv. This date seems to be hard coded in the m4_data.py file at 114 line. If my issue is correct, I hope it helps.
best regards
Adrien

Why is numpy==1.16.1 the only numpy version compatible with ESRNN?

Hi there,

I am working on building a forecasting ensemble pipeline that leverages a few different open source forecasting models, ESRNN, Keras, FBprophet, etc.

However, ESRNN is the only one that has an exact numpy version requirement, which is an older version than the rest of the libraries require. I am wondering why this is the only numpy version compatible with the library? It makes it impossible to ensemble it with any other library.

problem when executing the example of m4 (tensor problem)

Hi,
I got error below :
RuntimeError: Input and hidden tensors are not at the same device, found input tensor at cpu and hidden tensor at cuda:0

when executing the example of m4 :
`X_train_df, y_train_df, X_test_df, y_test_df = prepare_m4_data(dataset_name='Yearly',
directory = './data',
num_obs=1000)

Instantiate model

model = ESRNN(max_epochs=25, freq_of_test=5, batch_size=4, learning_rate=1e-4,
per_series_lr_multip=0.8, lr_scheduler_step_size=10,
lr_decay=0.1, gradient_clipping_threshold=50,
rnn_weight_decay=0.0, level_variability_penalty=100,
testing_percentile=50, training_percentile=50,
ensemble=False, max_periods=25, seasonality=[],
input_size=4, output_size=6,
cell_type='LSTM', state_hsize=40,
dilations=[[1], [6]], add_nl_layer=False,
random_seed=1, device='cpu')

Fit model

If y_test_df is provided the model

will evaluate predictions on

this set every freq_test epochs

model.fit(X_train_df, y_train_df, X_test_df, y_test_df)

Predict on test set

y_hat_df = model.predict(X_test_df)

Evaluate predictions

final_owa, final_mase, final_smape = evaluate_prediction_owa(y_hat_df, y_train_df,
X_test_df, y_test_df,
naive2_seasonality=1)`

full eror message :
`Infered frequency: D
=============== Training ESRNN ===============


RuntimeError Traceback (most recent call last)
in
19 # will evaluate predictions on
20 # this set every freq_test epochs
---> 21 model.fit(X_train_df, y_train_df, X_test_df, y_test_df)
22
23 # Predict on test set

~\Anaconda3\envs\nlp\lib\site-packages\ESRNN\ESRNN.py in fit(self, X_df, y_df, X_test_df, y_test_df, y_hat_benchmark, warm_start, shuffle, verbose)
366 self._fitted = True
367 self.train(dataloader=self.train_dataloader, max_epochs=self.mc.max_epochs,
--> 368 warm_start=warm_start, shuffle=shuffle, verbose=verbose)
369
370 def instantiate_esrnn(self, exogenous_size, n_series):

~\Anaconda3\envs\nlp\lib\site-packages\ESRNN\ESRNN.py in train(self, dataloader, max_epochs, warm_start, shuffle, verbose)
184
185 batch = dataloader.get_batch()
--> 186 windows_y, windows_y_hat, levels = self.esrnn(batch)
187
188 # Pinball loss on normalized values

~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs)
548 result = self._slow_forward(*input, **kwargs)
549 else:
--> 550 result = self.forward(*input, **kwargs)
551 for hook in self._forward_hooks.values():
552 hook_result = hook(self, input, result)

~\Anaconda3\envs\nlp\lib\site-packages\ESRNN\utils\ESRNN.py in forward(self, ts_object)
274
275 # RNN Forward
--> 276 windows_y_hat = self.rnn(windows_y_hat)
277
278 return windows_y, windows_y_hat, levels

~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs)
548 result = self._slow_forward(*input, **kwargs)
549 else:
--> 550 result = self.forward(*input, **kwargs)
551 for hook in self._forward_hooks.values():
552 hook_result = hook(self, input, result)

~\Anaconda3\envs\nlp\lib\site-packages\ESRNN\utils\ESRNN.py in forward(self, input_data)
249 for layer_num in range(len(self.rnn_stack)):
250 residual = input_data
--> 251 output, _ = self.rnn_stacklayer_num
252 if layer_num > 0:
253 output += residual

~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs)
548 result = self._slow_forward(*input, **kwargs)
549 else:
--> 550 result = self.forward(*input, **kwargs)
551 for hook in self._forward_hooks.values():
552 hook_result = hook(self, input, result)

~\Anaconda3\envs\nlp\lib\site-packages\ESRNN\utils\DRNN.py in forward(self, inputs, hidden)
181 for i, (cell, dilation) in enumerate(zip(self.cells, self.dilations)):
182 if hidden is None:
--> 183 inputs, _ = self.drnn_layer(cell, inputs, dilation)
184 else:
185 inputs, hidden[i] = self.drnn_layer(cell, inputs, dilation, hidden[i])

~\Anaconda3\envs\nlp\lib\site-packages\ESRNN\utils\DRNN.py in drnn_layer(self, cell, inputs, rate, hidden)
201
202 if hidden is None:
--> 203 dilated_outputs, hidden = self._apply_cell(dilated_inputs, cell, batch_size, rate, hidden_size)
204 else:
205 hidden = self._prepare_inputs(hidden, rate)

~\Anaconda3\envs\nlp\lib\site-packages\ESRNN\utils\DRNN.py in _apply_cell(self, dilated_inputs, cell, batch_size, rate, hidden_size, hidden)
220 hidden = self.init_hidden(batch_size * rate, hidden_size).unsqueeze(0)
221
--> 222 dilated_outputs, hidden = cell(dilated_inputs, hidden) # compatibility hack
223
224 return dilated_outputs, hidden

~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs)
548 result = self._slow_forward(*input, **kwargs)
549 else:
--> 550 result = self.forward(*input, **kwargs)
551 for hook in self._forward_hooks.values():
552 hook_result = hook(self, input, result)

~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\modules\rnn.py in forward(self, input, hx)
568 if batch_sizes is None:
569 result = _VF.lstm(input, hx, self._flat_weights, self.bias, self.num_layers,
--> 570 self.dropout, self.training, self.bidirectional, self.batch_first)
571 else:
572 result = _VF.lstm(input, batch_sizes, hx, self._flat_weights, self.bias,

RuntimeError: Input and hidden tensors are not at the same device, found input tensor at cpu and hidden tensor at cuda:0`

How to prepare the data format?

I have read the Medium example and executed the example. I understand from the README that X_df must contain the columns ['unique_id', 'ds', 'x'] and y_df must contain the columns ['unique_id', 'ds', 'y'].

Now in my case I have:

     time              usage        requests  hits 
5    1.589360e+12  1575.6520        5074.0  1588.0
12   1.589360e+12  1575.6520        5074.0  1588.0
19   1.589360e+12  1527.7666        5042.0  1580.0
26   1.589360e+12  1527.7666        5042.0  1580.0
33   1.589360e+12  1477.7880        5297.0  1584.0
...

and I want to predict usage. How should I map my data to the required input format? I can only think of time getting mapped to ds.

I have read many issues (such as this one), but I wasn't able to figure out how to map my data.

ModuleNotFoundError: No module named 'ESRNN.m4_data'; 'ESRNN' is not a package

Hello,

I've tried to install ESRNN via the instruction in this link: https://pypi.org/project/ESRNN/
which were: pip install ESRNN

However, when I try to run the follow code:

from ESRNN.m4_data import prepare_m4_data
from ESRNN.utils_evaluation import evaluate_prediction_owa

from ESRNN import ESRNN

I get the following error:

Traceback (most recent call last):
File "ESRNN.py", line 2, in
from ESRNN.m4_data import prepare_m4_data
File "C:\Users\mario\Documents\Python Benjamin\ESRNN.py", line 2, in
from ESRNN.m4_data import prepare_m4_data
ModuleNotFoundError: No module named 'ESRNN.m4_data'; 'ESRNN' is not a package

I've tried adding ESRNN as a path variable and still get the same error.

Could anyone please assist?

Save functionality broken; ESRNN Model Object structure not reflected in save & load

There seems to be an issue with the save function for the ESRNN model. When running

model = ESRNN()

model.save('esrnn_weights.model')

The following error occurs:

---------------------------------------------------
AttributeError    Traceback (most recent call last)
<ipython-input-28-4822649eb25a> in <module>
----> 1 model.save('esrnn_weights.model')

~/.local/lib/python3.8/site-packages/ESRNN/ESRNN.py in save(self, model_dir, copy)
    494 
    495     print('Saving model to:\n {}'.format(model_dir)+'\n')
--> 496     torch.save({'model_state_dict': self.es.state_dict()}, es_filepath)
    497     torch.save({'model_state_dict': self.rnn.state_dict()}, rnn_filepath)
    498 

AttributeError: 'ESRNN' object has no attribute 'es'

While exploring this, the I found that the 'save' function is referencing es, mc and rnn, none of which are in the top level of the ESRNN object (self) but in self.esrnn (this can be confirmed with dir(model) and dir(model.esrnn).

In the present state of the project, saving models requires a fair bit of hacking

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.