Multi-Step Forecast for Multivariate Time Series (LSTM) Keras












0












$begingroup$


I have been trying to understand how to build LSTM model for multivariate time series forecast using Keras but I am still unsure how to present the data in the correct shape.



My Dataset:
• 5 cities.
• Each with 2 features. Temperature and humidity.
• Daily records of the last 10 weeks(Monday, Tuesday, …, Sunday)


What I want to do:



Given Monday’s record of the new week of a city, I'd like to forecast the Temperature and humidity for the remaining 6 days of that city. I.e. Multi-Step Forecast for Multivariate Time Series. Output shape(6,2)



How I have started off:



For each city, the input shape [(num_samples, num_time_steps, num_features) ] would be (10, 7, 2).



For 10 weeks, I will have five unique samples(5-cities) with the same shape (70, 2). So if I stack all vertically I will have (350, 2) or 3D shape (50,7,2).
Then create a supervised series with lag 1, I will have a shape(244, 4)



# Split train/test data. 
train on 7-weeks. So input_shape= 5*(7,7,2) = (35,7,2)
test on 3-weeks. . So input_shape= 5*(3,7,2) = (15,7, 2)


What I am confused about:



The above layout seems to disregard the unique nature of each sample. I looked at this but still a bit confused about how to transform it to a regression model.



I want the network to train each city's data separately as in this pic
I would appreciate any suggestion.
Thanks










share|improve this question









$endgroup$

















    0












    $begingroup$


    I have been trying to understand how to build LSTM model for multivariate time series forecast using Keras but I am still unsure how to present the data in the correct shape.



    My Dataset:
    • 5 cities.
    • Each with 2 features. Temperature and humidity.
    • Daily records of the last 10 weeks(Monday, Tuesday, …, Sunday)


    What I want to do:



    Given Monday’s record of the new week of a city, I'd like to forecast the Temperature and humidity for the remaining 6 days of that city. I.e. Multi-Step Forecast for Multivariate Time Series. Output shape(6,2)



    How I have started off:



    For each city, the input shape [(num_samples, num_time_steps, num_features) ] would be (10, 7, 2).



    For 10 weeks, I will have five unique samples(5-cities) with the same shape (70, 2). So if I stack all vertically I will have (350, 2) or 3D shape (50,7,2).
    Then create a supervised series with lag 1, I will have a shape(244, 4)



    # Split train/test data. 
    train on 7-weeks. So input_shape= 5*(7,7,2) = (35,7,2)
    test on 3-weeks. . So input_shape= 5*(3,7,2) = (15,7, 2)


    What I am confused about:



    The above layout seems to disregard the unique nature of each sample. I looked at this but still a bit confused about how to transform it to a regression model.



    I want the network to train each city's data separately as in this pic
    I would appreciate any suggestion.
    Thanks










    share|improve this question









    $endgroup$















      0












      0








      0





      $begingroup$


      I have been trying to understand how to build LSTM model for multivariate time series forecast using Keras but I am still unsure how to present the data in the correct shape.



      My Dataset:
      • 5 cities.
      • Each with 2 features. Temperature and humidity.
      • Daily records of the last 10 weeks(Monday, Tuesday, …, Sunday)


      What I want to do:



      Given Monday’s record of the new week of a city, I'd like to forecast the Temperature and humidity for the remaining 6 days of that city. I.e. Multi-Step Forecast for Multivariate Time Series. Output shape(6,2)



      How I have started off:



      For each city, the input shape [(num_samples, num_time_steps, num_features) ] would be (10, 7, 2).



      For 10 weeks, I will have five unique samples(5-cities) with the same shape (70, 2). So if I stack all vertically I will have (350, 2) or 3D shape (50,7,2).
      Then create a supervised series with lag 1, I will have a shape(244, 4)



      # Split train/test data. 
      train on 7-weeks. So input_shape= 5*(7,7,2) = (35,7,2)
      test on 3-weeks. . So input_shape= 5*(3,7,2) = (15,7, 2)


      What I am confused about:



      The above layout seems to disregard the unique nature of each sample. I looked at this but still a bit confused about how to transform it to a regression model.



      I want the network to train each city's data separately as in this pic
      I would appreciate any suggestion.
      Thanks










      share|improve this question









      $endgroup$




      I have been trying to understand how to build LSTM model for multivariate time series forecast using Keras but I am still unsure how to present the data in the correct shape.



      My Dataset:
      • 5 cities.
      • Each with 2 features. Temperature and humidity.
      • Daily records of the last 10 weeks(Monday, Tuesday, …, Sunday)


      What I want to do:



      Given Monday’s record of the new week of a city, I'd like to forecast the Temperature and humidity for the remaining 6 days of that city. I.e. Multi-Step Forecast for Multivariate Time Series. Output shape(6,2)



      How I have started off:



      For each city, the input shape [(num_samples, num_time_steps, num_features) ] would be (10, 7, 2).



      For 10 weeks, I will have five unique samples(5-cities) with the same shape (70, 2). So if I stack all vertically I will have (350, 2) or 3D shape (50,7,2).
      Then create a supervised series with lag 1, I will have a shape(244, 4)



      # Split train/test data. 
      train on 7-weeks. So input_shape= 5*(7,7,2) = (35,7,2)
      test on 3-weeks. . So input_shape= 5*(3,7,2) = (15,7, 2)


      What I am confused about:



      The above layout seems to disregard the unique nature of each sample. I looked at this but still a bit confused about how to transform it to a regression model.



      I want the network to train each city's data separately as in this pic
      I would appreciate any suggestion.
      Thanks







      machine-learning keras time-series lstm






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 5 hours ago









      Abs Abs

      264




      264






















          0






          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "557"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f45228%2fmulti-step-forecast-for-multivariate-time-series-lstm-keras%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Data Science Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f45228%2fmulti-step-forecast-for-multivariate-time-series-lstm-keras%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Callistus I

          Tabula Rosettana

          How to label and detect the document text images