{
  "id": 45226,
  "title": "did anyone apply LSTM",
  "url": "/competitions/favorita-grocery-sales-forecasting/discussion/45226",
  "author_name": "",
  "post_date": "2017-12-08T01:25:33.380939800Z",
  "votes": 7,
  "comment_count": 9,
  "views": 0,
  "content": "<p>Hi,\nI applied LSTM for the unit Sales data.  LSTM catches the trend but not the values.  Any idea how to improve it?</p>",
  "messages": [
    {
      "id": "254979",
      "postDate": "12/08/2017 01:25:33",
      "content": "<p>Hi,\nI applied LSTM for the unit Sales data.  LSTM catches the trend but not the values.  Any idea how to improve it?</p>",
      "rawMarkdown": "Hi,\nI applied LSTM for the unit Sales data.  LSTM catches the trend but not the values.  Any idea how to improve it?",
      "votes": null
    },
    {
      "id": "254981",
      "postDate": "12/08/2017 01:32:45",
      "content": "<p>I currently working an an lstm model. \nWhat do you mean that the lstm is producing trends but not values? Do you mean that the model output is too smooth or that it's not of the right order of magnitude? </p>",
      "rawMarkdown": "I currently working an an lstm model. \nWhat do you mean that the lstm is producing trends but not values? Do you mean that the model output is too smooth or that it's not of the right order of magnitude?",
      "votes": null
    },
    {
      "id": "254988",
      "postDate": "12/08/2017 01:40:48",
      "content": "<p>Hi Michael,\nsomehow I can't post the plot here.  for eg, if the actual value varies from 5 to 450, the predicted value varies from 200 to 300.  But when actual value has increasing trend, predicted values shows a increasing trend.  I used LSTM model to look back 15 days and added holiday, payday and oil price as additional columns.  So, my training set has the dimension of (n-14) x 19 where n is the number of observations.  I did for only one family for one store.  If this works, I was planning to use Multivariate LSTM to predict the unit sales across all stores for all products</p>",
      "rawMarkdown": "Hi Michael,\nsomehow I can't post the plot here.  for eg, if the actual value varies from 5 to 450, the predicted value varies from 200 to 300.  But when actual value has increasing trend, predicted values shows a increasing trend.  I used LSTM model to look back 15 days and added holiday, payday and oil price as additional columns.  So, my training set has the dimension of (n-14) x 19 where n is the number of observations.  I did for only one family for one store.  If this works, I was planning to use Multivariate LSTM to predict the unit sales across all stores for all products",
      "votes": null
    },
    {
      "id": "255004",
      "postDate": "12/08/2017 03:14:13",
      "content": "<p>I would consider this a success and move on to a more complex model. Its extremely common for models to predict with a smaller variance than the input, especially when input data is missing. </p>\n\n<p>If you continue to run into the problem as you add more information into the model, additional layers can help the model take on more complex behavior. Additionally, Day of the Week info can help the model with some products that spike on weekends. </p>",
      "rawMarkdown": "I would consider this a success and move on to a more complex model. Its extremely common for models to predict with a smaller variance than the input, especially when input data is missing. \n\nIf you continue to run into the problem as you add more information into the model, additional layers can help the model take on more complex behavior. Additionally, Day of the Week info can help the model with some products that spike on weekends.",
      "votes": null
    },
    {
      "id": "258237",
      "postDate": "12/15/2017 19:29:34",
      "content": "<p>I am new to LSTM, and trying to work on it. May I ask how you combine the sequential features with non-sequential features(eg. promotion, city)? </p>\n\n<p>For the non-sequential part, should I add them as inputs in some dense layers of the LSTM model, or should I build a separate model (like xgboost) to predict sales and weight the results with LSTM model to get the final prediction? Thanks.</p>",
      "rawMarkdown": "I am new to LSTM, and trying to work on it. May I ask how you combine the sequential features with non-sequential features(eg. promotion, city)? \n\nFor the non-sequential part, should I add them as inputs in some dense layers of the LSTM model, or should I build a separate model (like xgboost) to predict sales and weight the results with LSTM model to get the final prediction? Thanks.",
      "votes": null
    },
    {
      "id": "258269",
      "postDate": "12/15/2017 21:22:05",
      "content": "<p>I basically just repeat the static features and concatenate  them with the dynamic features associated with each day in the prediction range. This isn't typically best practice but it's been working well. </p>",
      "rawMarkdown": "I basically just repeat the static features and concatenate  them with the dynamic features associated with each day in the prediction range. This isn't typically best practice but it's been working well.",
      "votes": null
    },
    {
      "id": "267195",
      "postDate": "01/10/2018 20:37:33",
      "content": "<p>I'm curious how could we apply LSTM across all stores and all products. It's intuitive to do it for just one product of a specific store, but how could we organize the input for multiple stores/products? For example, in Keras, the input of LSTM cell should have a dimension of (num_samples, time_step, features), if we do it for multiple stores, there would be some duplicated dates at time step. Anyone has any idea?</p>",
      "rawMarkdown": "I'm curious how could we apply LSTM across all stores and all products. It's intuitive to do it for just one product of a specific store, but how could we organize the input for multiple stores/products? For example, in Keras, the input of LSTM cell should have a dimension of (num_samples, time_step, features), if we do it for multiple stores, there would be some duplicated dates at time step. Anyone has any idea?",
      "votes": null
    },
    {
      "id": "267229",
      "postDate": "01/10/2018 22:10:09",
      "content": "<p>Disclaimer: I had absolutely no knowledge about LSTM before entering this competition and my first submission isn't satisfying... and I build my code in Keras from scratch since I wanted to understand all the steps and mess with it which took me a really long time.</p>\n\n<p>To answer your question, I tried to deal with this problem of dates/multiples stores/multiple products by including the stores into the features. In other word, the sequences are built by filtering the data table by item_id and store_id and then by taking X successive dates. A batch (num_samples) is then constituted by Y different sequences at random.</p>\n\n<p>Let me know your comments please.</p>",
      "rawMarkdown": "Disclaimer: I had absolutely no knowledge about LSTM before entering this competition and my first submission isn't satisfying... and I build my code in Keras from scratch since I wanted to understand all the steps and mess with it which took me a really long time.\n\nTo answer your question, I tried to deal with this problem of dates/multiples stores/multiple products by including the stores into the features. In other word, the sequences are built by filtering the data table by item_id and store_id and then by taking X successive dates. A batch (num_samples) is then constituted by Y different sequences at random.\n\nLet me know your comments please.",
      "votes": null
    },
    {
      "id": "267237",
      "postDate": "01/10/2018 22:22:02",
      "content": "<p>Not sure if I understand you correctly, it looks like you're trying to re-order the table(training set) so that the 'date' column has consecutive value. For example, you might have Item A of Store 1 in the first 100 rows of the table, whose 'date' might be the first 100 days of 2013. And then comes Item B of Store 1 in the next N rows of the table. </p>\n\n<p>Not sure if this is a good way approaching the problem, because 1) items might not be sold on consecutive days, 2) each item of each store are sold different times, and that means the 'time step' at LSTM would be different for items. </p>\n\n<p>I am considering seriously not thinking this problem as a time-series problem, what do you think?</p>",
      "rawMarkdown": "Not sure if I understand you correctly, it looks like you're trying to re-order the table(training set) so that the 'date' column has consecutive value. For example, you might have Item A of Store 1 in the first 100 rows of the table, whose 'date' might be the first 100 days of 2013. And then comes Item B of Store 1 in the next N rows of the table. \n\nNot sure if this is a good way approaching the problem, because 1) items might not be sold on consecutive days, 2) each item of each store are sold different times, and that means the 'time step' at LSTM would be different for items. \n\nI am considering seriously not thinking this problem as a time-series problem, what do you think?",
      "votes": null
    },
    {
      "id": "267258",
      "postDate": "01/10/2018 23:05:31",
      "content": "<p>I have the same question \"is this problem a time series problem?\" but my problem is more on the item for which there isn't any recent history in the train set.\nAnyway, you would need to include in your training data the previous states of unit_sales in order to predict the future unit_sales.</p>\n\n<p>Regarding 1), I implemented the missing dates with a NA state which seems to work better and regarding 2), I only considered constant 'time step' for simplicity and I will try to see if I can implement variable time steps.</p>",
      "rawMarkdown": "I have the same question \"is this problem a time series problem?\" but my problem is more on the item for which there isn't any recent history in the train set.\nAnyway, you would need to include in your training data the previous states of unit_sales in order to predict the future unit_sales.\n\nRegarding 1), I implemented the missing dates with a NA state which seems to work better and regarding 2), I only considered constant 'time step' for simplicity and I will try to see if I can implement variable time steps.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 254981,
      "author_name": "vannak",
      "author_url": "",
      "post_date": "12/08/2017 01:32:45",
      "content": "<p>I currently working an an lstm model. \nWhat do you mean that the lstm is producing trends but not values? Do you mean that the model output is too smooth or that it's not of the right order of magnitude? </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 254988,
      "author_name": "narasimmanr",
      "author_url": "",
      "post_date": "12/08/2017 01:40:48",
      "content": "<p>Hi Michael,\nsomehow I can't post the plot here.  for eg, if the actual value varies from 5 to 450, the predicted value varies from 200 to 300.  But when actual value has increasing trend, predicted values shows a increasing trend.  I used LSTM model to look back 15 days and added holiday, payday and oil price as additional columns.  So, my training set has the dimension of (n-14) x 19 where n is the number of observations.  I did for only one family for one store.  If this works, I was planning to use Multivariate LSTM to predict the unit sales across all stores for all products</p>",
      "votes": null,
      "replies": [
        {
          "id": 255004,
          "author_name": "vannak",
          "author_url": "",
          "post_date": "12/08/2017 03:14:13",
          "content": "<p>I would consider this a success and move on to a more complex model. Its extremely common for models to predict with a smaller variance than the input, especially when input data is missing. </p>\n\n<p>If you continue to run into the problem as you add more information into the model, additional layers can help the model take on more complex behavior. Additionally, Day of the Week info can help the model with some products that spike on weekends. </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 258237,
      "author_name": "floralqy",
      "author_url": "",
      "post_date": "12/15/2017 19:29:34",
      "content": "<p>I am new to LSTM, and trying to work on it. May I ask how you combine the sequential features with non-sequential features(eg. promotion, city)? </p>\n\n<p>For the non-sequential part, should I add them as inputs in some dense layers of the LSTM model, or should I build a separate model (like xgboost) to predict sales and weight the results with LSTM model to get the final prediction? Thanks.</p>",
      "votes": null,
      "replies": [
        {
          "id": 258269,
          "author_name": "vannak",
          "author_url": "",
          "post_date": "12/15/2017 21:22:05",
          "content": "<p>I basically just repeat the static features and concatenate  them with the dynamic features associated with each day in the prediction range. This isn't typically best practice but it's been working well. </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 267195,
      "author_name": "bdeng3",
      "author_url": "",
      "post_date": "01/10/2018 20:37:33",
      "content": "<p>I'm curious how could we apply LSTM across all stores and all products. It's intuitive to do it for just one product of a specific store, but how could we organize the input for multiple stores/products? For example, in Keras, the input of LSTM cell should have a dimension of (num_samples, time_step, features), if we do it for multiple stores, there would be some duplicated dates at time step. Anyone has any idea?</p>",
      "votes": null,
      "replies": [
        {
          "id": 267229,
          "author_name": "chabir",
          "author_url": "",
          "post_date": "01/10/2018 22:10:09",
          "content": "<p>Disclaimer: I had absolutely no knowledge about LSTM before entering this competition and my first submission isn't satisfying... and I build my code in Keras from scratch since I wanted to understand all the steps and mess with it which took me a really long time.</p>\n\n<p>To answer your question, I tried to deal with this problem of dates/multiples stores/multiple products by including the stores into the features. In other word, the sequences are built by filtering the data table by item_id and store_id and then by taking X successive dates. A batch (num_samples) is then constituted by Y different sequences at random.</p>\n\n<p>Let me know your comments please.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 267237,
          "author_name": "bdeng3",
          "author_url": "",
          "post_date": "01/10/2018 22:22:02",
          "content": "<p>Not sure if I understand you correctly, it looks like you're trying to re-order the table(training set) so that the 'date' column has consecutive value. For example, you might have Item A of Store 1 in the first 100 rows of the table, whose 'date' might be the first 100 days of 2013. And then comes Item B of Store 1 in the next N rows of the table. </p>\n\n<p>Not sure if this is a good way approaching the problem, because 1) items might not be sold on consecutive days, 2) each item of each store are sold different times, and that means the 'time step' at LSTM would be different for items. </p>\n\n<p>I am considering seriously not thinking this problem as a time-series problem, what do you think?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 267258,
          "author_name": "chabir",
          "author_url": "",
          "post_date": "01/10/2018 23:05:31",
          "content": "<p>I have the same question \"is this problem a time series problem?\" but my problem is more on the item for which there isn't any recent history in the train set.\nAnyway, you would need to include in your training data the previous states of unit_sales in order to predict the future unit_sales.</p>\n\n<p>Regarding 1), I implemented the missing dates with a NA state which seems to work better and regarding 2), I only considered constant 'time step' for simplicity and I will try to see if I can implement variable time steps.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "254979": "Hi,\nI applied LSTM for the unit Sales data.  LSTM catches the trend but not the values.  Any idea how to improve it?",
    "254981": "I currently working an an lstm model. \nWhat do you mean that the lstm is producing trends but not values? Do you mean that the model output is too smooth or that it's not of the right order of magnitude?",
    "254988": "Hi Michael,\nsomehow I can't post the plot here.  for eg, if the actual value varies from 5 to 450, the predicted value varies from 200 to 300.  But when actual value has increasing trend, predicted values shows a increasing trend.  I used LSTM model to look back 15 days and added holiday, payday and oil price as additional columns.  So, my training set has the dimension of (n-14) x 19 where n is the number of observations.  I did for only one family for one store.  If this works, I was planning to use Multivariate LSTM to predict the unit sales across all stores for all products",
    "255004": "I would consider this a success and move on to a more complex model. Its extremely common for models to predict with a smaller variance than the input, especially when input data is missing. \n\nIf you continue to run into the problem as you add more information into the model, additional layers can help the model take on more complex behavior. Additionally, Day of the Week info can help the model with some products that spike on weekends.",
    "258237": "I am new to LSTM, and trying to work on it. May I ask how you combine the sequential features with non-sequential features(eg. promotion, city)? \n\nFor the non-sequential part, should I add them as inputs in some dense layers of the LSTM model, or should I build a separate model (like xgboost) to predict sales and weight the results with LSTM model to get the final prediction? Thanks.",
    "258269": "I basically just repeat the static features and concatenate  them with the dynamic features associated with each day in the prediction range. This isn't typically best practice but it's been working well.",
    "267195": "I'm curious how could we apply LSTM across all stores and all products. It's intuitive to do it for just one product of a specific store, but how could we organize the input for multiple stores/products? For example, in Keras, the input of LSTM cell should have a dimension of (num_samples, time_step, features), if we do it for multiple stores, there would be some duplicated dates at time step. Anyone has any idea?",
    "267229": "Disclaimer: I had absolutely no knowledge about LSTM before entering this competition and my first submission isn't satisfying... and I build my code in Keras from scratch since I wanted to understand all the steps and mess with it which took me a really long time.\n\nTo answer your question, I tried to deal with this problem of dates/multiples stores/multiple products by including the stores into the features. In other word, the sequences are built by filtering the data table by item_id and store_id and then by taking X successive dates. A batch (num_samples) is then constituted by Y different sequences at random.\n\nLet me know your comments please.",
    "267237": "Not sure if I understand you correctly, it looks like you're trying to re-order the table(training set) so that the 'date' column has consecutive value. For example, you might have Item A of Store 1 in the first 100 rows of the table, whose 'date' might be the first 100 days of 2013. And then comes Item B of Store 1 in the next N rows of the table. \n\nNot sure if this is a good way approaching the problem, because 1) items might not be sold on consecutive days, 2) each item of each store are sold different times, and that means the 'time step' at LSTM would be different for items. \n\nI am considering seriously not thinking this problem as a time-series problem, what do you think?",
    "267258": "I have the same question \"is this problem a time series problem?\" but my problem is more on the item for which there isn't any recent history in the train set.\nAnyway, you would need to include in your training data the previous states of unit_sales in order to predict the future unit_sales.\n\nRegarding 1), I implemented the missing dates with a NA state which seems to work better and regarding 2), I only considered constant 'time step' for simplicity and I will try to see if I can implement variable time steps."
  },
  "source": "meta"
}