Skip to content

Consultation on AR-LSTM prediction issues #17

Description

@Reo-yan

Hi, teacher marcopeix:
I'm currently studying the book "Time-Series-Forecasting in-Python". I really like the time series prediction method and thanks for your github code sharing.

 However, there are also some questions I need during my study process, which puzzles me a lot.

 Taking Chapter 17 of this book, AR-LSTM, as an example, we gave a model evaluation on the data and proved that AR-LSTM is a relatively appropriate model. This is comforting. But the problem that follows is, how can I use the AR-LSTM model to predict the test dataset and getting the predicted values.

After running the code in CH17.ipynb,I continued to run the following code:

The inverse minmaxscaler method I used is as follows:

scaler = MinMaxScaler()
scaler.fit(train_df)
Restore using the scaler.inverse_transform() method.

The prediction method for the test set is as follows:

test_predictions_scaled = AR_LSTM.predict(multi_window.test)

The resulting test_predictions_scaled is a numpy array with dimensions of: (1709, 24, 5)

test_predictions_scaled sample data:

array([[[0.09379353, 0.07652892, 0.09657007, 0.11072036, 0.11131918],
[0.04895833, 0.06484775, 0.03994162, 0.0662628 , 0.05923389],
[0.03269311, 0.06338501, 0.03825416, 0.06969497, 0.06171504],
...,
[0.24172495, 0.24662721, 0.25657123, 0.2510248 , 0.25501385],
[0.16440384, 0.16854419, 0.18737686, 0.17829569, 0.17556214],
[0.09430677, 0.09476103, 0.11893123, 0.10730372, 0.10237038]],
...,
[0.6324826 , 0.62707186, 0.62948847, 0.6140796 , 0.62807786],
[0.6725644 , 0.6729528 , 0.65185994, 0.66380966, 0.67474675],
[0.6586775 , 0.6655749 , 0.6467061 , 0.658816 , 0.6668321 ]]],
shape=(1709, 24, 5), dtype=float32)

But in fact, our test set is a dataframe with a dimension of 1756 rows and 5 columns.

I very much hope that the prediction result of AR_LSTM is a value of 1756 rows and add 'AR-LSTM' column. However, it seems that ar_lstm.predict cannot return what I want. Is there any way to achieve this?

I guess that by doing some kind of combinatorial transformation on test_predictions_scaled, combined with scaler.inverse_transform(), I should be able to get the result I want, but I have never found it.

I hope you can help me solve my doubts. Thank you again.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions