{
  "id": 47575,
  "title": "6th Place Solution Overview",
  "url": "/competitions/favorita-grocery-sales-forecasting/writeups/eran-nicolas-keuipo-6th-place-solution-overview",
  "author_name": "",
  "post_date": "2018-01-17T13:41:30.173Z",
  "votes": 18,
  "comment_count": 3,
  "views": 0,
  "content": "<p>The 6th place solution was an ensemble of two solutions that score .517 privately (top 40).  Here is my top 40 solution:  </p>\n\n<h2>Basic Outline</h2>\n\n<ul>\n<li>LGBM Framework which used only 2017 data.</li>\n<li>Over 500 features.</li>\n<li>Fairly reliable cross-validation on 07-26 --&gt; 08/10</li>\n</ul>\n\n<h2>Features</h2>\n\n<p>These are the most important features. The following order reflects importance; however, by nature of having 16 models, there is no exact order. Unless otherwise noted, this was all done at the item-store level.  </p>\n\n<ul>\n<li>ma_median * isd_avg / isd_week_avg - popularized early on in the competition.  </li>\n<li>ma_median - Coupled with binary for whether or not it is equal to 0.  </li>\n<li>Day-of-week averages - Different time periods including 7, 14, 28, 56, 112.  </li>\n<li>Days since appeared - Difference between the 'start date' of the training cycle and the first date the item showed up in the original train file.</li>\n<li>Quantiles for several different time-spans.  </li>\n<li>Whether the item will be onpromotion.  </li>\n<li>Simple averages for different time-spans.  </li>\n<li>Item-cluster means - The past 5-day mean was a good predictor.  </li>\n<li>Future promotional 'sums' - E.g: sum of onpromotion 8/16 through 8/18.  </li>\n<li>mean_no_zero_sales - Mean of instances where unit_sales &gt; 0.  </li>\n<li>Frequency encoding - calculate the frequency of appearance for items, stores, families and classes (four columns that each sum to 1).  </li>\n</ul>\n\n<p>The above predictors consistently showed up as important predictors, or made immediate score advancements. The following predictors definitely helped as a whole:  </p>\n\n<ul>\n<li>One-hot-encoding clusters, states, types, cities and families.  </li>\n<li>Weekend and weekday means.  </li>\n<li>Staggered mean data (e.g. 8/07 --&gt; 8/14 for the test-set).  </li>\n<li>Staggered quantile data.  </li>\n<li>Past number of zero sales for different time-spans.  </li>\n<li>Past number of promotional days.  </li>\n<li>Past promotional sales averages.  </li>\n<li>Past day-of-week quantile data.  </li>\n</ul>\n\n<h2>Final Submission</h2>\n\n<p>Mentioned earlier, this is a top-40 solution on it's own. My teammate, <a href=\"https://www.kaggle.com/eranah\">Eran</a>, was scoring similarly. He also used LGBM, but we had quite different Feature Engineering. Specifically, we had different top predictors and we generally used different time-spans. We each ran our models about 5 times and created a final ensemble - the 6th place solution at .514 (.507 public LB).  </p>\n\n<h2>Some Thoughts</h2>\n\n<ul>\n<li>This was a supply-demand problem. In a more realistic setting, knowing which days stores get product for restocking, and potentially Retail Management Software data (i.e. data on when products are being pulled from the backroom) would make prediction a lot easier.  </li>\n<li>I did not worry about the onpromotion bias. The data-set is very complex, and 'filling in the blanks' seemed unrealistic. If an item was on promotion, but had 0 unit_sales, then it either is very low demand or out-of-stock.  </li>\n<li>The only certain way to know if a new item-store combination is 'real' is if it was on promotion at some point during the test-set days.  </li>\n<li>Having your model data start from 8/9 and predicting 8-16 --&gt; 8-20 can be useful to see how it will do for the private leader board.  </li>\n<li>Examining which items were getting predicted poorly in the validation set was very useful for coming up with feature ideas.  </li>\n</ul>",
  "messages": [
    {
      "id": "269274",
      "postDate": "01/16/2018 15:14:53",
      "content": "<p>The 6th place solution was an ensemble of two solutions that score .517 privately (top 40).  Here is my top 40 solution:  </p>\n\n<h2>Basic Outline</h2>\n\n<ul>\n<li>LGBM Framework which used only 2017 data.</li>\n<li>Over 500 features.</li>\n<li>Fairly reliable cross-validation on 07-26 --&gt; 08/10</li>\n</ul>\n\n<h2>Features</h2>\n\n<p>These are the most important features. The following order reflects importance; however, by nature of having 16 models, there is no exact order. Unless otherwise noted, this was all done at the item-store level.  </p>\n\n<ul>\n<li>ma_median * isd_avg / isd_week_avg - popularized early on in the competition.  </li>\n<li>ma_median - Coupled with binary for whether or not it is equal to 0.  </li>\n<li>Day-of-week averages - Different time periods including 7, 14, 28, 56, 112.  </li>\n<li>Days since appeared - Difference between the 'start date' of the training cycle and the first date the item showed up in the original train file.</li>\n<li>Quantiles for several different time-spans.  </li>\n<li>Whether the item will be onpromotion.  </li>\n<li>Simple averages for different time-spans.  </li>\n<li>Item-cluster means - The past 5-day mean was a good predictor.  </li>\n<li>Future promotional 'sums' - E.g: sum of onpromotion 8/16 through 8/18.  </li>\n<li>mean_no_zero_sales - Mean of instances where unit_sales &gt; 0.  </li>\n<li>Frequency encoding - calculate the frequency of appearance for items, stores, families and classes (four columns that each sum to 1).  </li>\n</ul>\n\n<p>The above predictors consistently showed up as important predictors, or made immediate score advancements. The following predictors definitely helped as a whole:  </p>\n\n<ul>\n<li>One-hot-encoding clusters, states, types, cities and families.  </li>\n<li>Weekend and weekday means.  </li>\n<li>Staggered mean data (e.g. 8/07 --&gt; 8/14 for the test-set).  </li>\n<li>Staggered quantile data.  </li>\n<li>Past number of zero sales for different time-spans.  </li>\n<li>Past number of promotional days.  </li>\n<li>Past promotional sales averages.  </li>\n<li>Past day-of-week quantile data.  </li>\n</ul>\n\n<h2>Final Submission</h2>\n\n<p>Mentioned earlier, this is a top-40 solution on it's own. My teammate, <a href=\"https://www.kaggle.com/eranah\">Eran</a>, was scoring similarly. He also used LGBM, but we had quite different Feature Engineering. Specifically, we had different top predictors and we generally used different time-spans. We each ran our models about 5 times and created a final ensemble - the 6th place solution at .514 (.507 public LB).  </p>\n\n<h2>Some Thoughts</h2>\n\n<ul>\n<li>This was a supply-demand problem. In a more realistic setting, knowing which days stores get product for restocking, and potentially Retail Management Software data (i.e. data on when products are being pulled from the backroom) would make prediction a lot easier.  </li>\n<li>I did not worry about the onpromotion bias. The data-set is very complex, and 'filling in the blanks' seemed unrealistic. If an item was on promotion, but had 0 unit_sales, then it either is very low demand or out-of-stock.  </li>\n<li>The only certain way to know if a new item-store combination is 'real' is if it was on promotion at some point during the test-set days.  </li>\n<li>Having your model data start from 8/9 and predicting 8-16 --&gt; 8-20 can be useful to see how it will do for the private leader board.  </li>\n<li>Examining which items were getting predicted poorly in the validation set was very useful for coming up with feature ideas.  </li>\n</ul>",
      "rawMarkdown": "The 6th place solution was an ensemble of two solutions that score .517 privately (top 40).  Here is my top 40 solution:  \n  \n##Basic Outline  \n- LGBM Framework which used only 2017 data.\n- Over 500 features.\n- Fairly reliable cross-validation on 07-26 --&gt; 08/10\n  \n## Features\nThese are the most important features. The following order reflects importance; however, by nature of having 16 models, there is no exact order. Unless otherwise noted, this was all done at the item-store level.  \n  \n- ma_median * isd_avg / isd_week_avg - popularized early on in the competition.  \n- ma_median - Coupled with binary for whether or not it is equal to 0.  \n- Day-of-week averages - Different time periods including 7, 14, 28, 56, 112.  \n- Days since appeared - Difference between the 'start date' of the training cycle and the first date the item showed up in the original train file.\n- Quantiles for several different time-spans.  \n- Whether the item will be onpromotion.  \n- Simple averages for different time-spans.  \n- Item-cluster means - The past 5-day mean was a good predictor.  \n- Future promotional 'sums' - E.g: sum of onpromotion 8/16 through 8/18.  \n- mean_no_zero_sales - Mean of instances where unit_sales &gt; 0.  \n- Frequency encoding - calculate the frequency of appearance for items, stores, families and classes (four columns that each sum to 1).  \n    \nThe above predictors consistently showed up as important predictors, or made immediate score advancements. The following predictors definitely helped as a whole:  \n  \n- One-hot-encoding clusters, states, types, cities and families.  \n- Weekend and weekday means.  \n- Staggered mean data (e.g. 8/07 --&gt; 8/14 for the test-set).  \n- Staggered quantile data.  \n- Past number of zero sales for different time-spans.  \n- Past number of promotional days.  \n- Past promotional sales averages.  \n- Past day-of-week quantile data.  \n    \n##Final Submission\nMentioned earlier, this is a top-40 solution on it's own. My teammate, [Eran][1], was scoring similarly. He also used LGBM, but we had quite different Feature Engineering. Specifically, we had different top predictors and we generally used different time-spans. We each ran our models about 5 times and created a final ensemble - the 6th place solution at .514 (.507 public LB).  \n  \n##Some Thoughts\n- This was a supply-demand problem. In a more realistic setting, knowing which days stores get product for restocking, and potentially Retail Management Software data (i.e. data on when products are being pulled from the backroom) would make prediction a lot easier.  \n- I did not worry about the onpromotion bias. The data-set is very complex, and 'filling in the blanks' seemed unrealistic. If an item was on promotion, but had 0 unit_sales, then it either is very low demand or out-of-stock.  \n- The only certain way to know if a new item-store combination is 'real' is if it was on promotion at some point during the test-set days.  \n- Having your model data start from 8/9 and predicting 8-16 --&gt; 8-20 can be useful to see how it will do for the private leader board.  \n- Examining which items were getting predicted poorly in the validation set was very useful for coming up with feature ideas.  \n\n\n\n  [1]: https://www.kaggle.com/eranah",
      "votes": null
    },
    {
      "id": "269364",
      "postDate": "01/16/2018 17:34:03",
      "content": "<p>I wonder what is your time span to calculate frequency.</p>",
      "rawMarkdown": "I wonder what is your time span to calculate frequency.",
      "votes": null
    },
    {
      "id": "269377",
      "postDate": "01/16/2018 18:04:11",
      "content": "<p>Two step process: <br>\n- Get all item/store combinations between 2017/01/01 and the start of the train cycle. <br>\n- For each item, divide number of appearances by total number of item/store combinations.</p>",
      "rawMarkdown": "Two step process:  \n- Get all item/store combinations between 2017/01/01 and the start of the train cycle.  \n- For each item, divide number of appearances by total number of item/store combinations.",
      "votes": null
    },
    {
      "id": "269568",
      "postDate": "01/17/2018 02:12:25",
      "content": "<blockquote>\n  <p>knowing which day stores get product for restocking, and potentially Retail Management Software data (i.e. data on when products are being pulled from the backroom) would make prediction a lot easier. </p>\n</blockquote>\n\n<p>Indeed, discussed this in the early days of the competition  in the forum.  Out of stock info in particular would have been great.</p>\n\n<p>Thanks for sharing, and congrats on the result!</p>",
      "rawMarkdown": "&gt;  knowing which day stores get product for restocking, and potentially Retail Management Software data (i.e. data on when products are being pulled from the backroom) would make prediction a lot easier. \n\nIndeed, discussed this in the early days of the competition  in the forum.  Out of stock info in particular would have been great.\n\nThanks for sharing, and congrats on the result!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 269364,
      "author_name": "yedthon",
      "author_url": "",
      "post_date": "01/16/2018 17:34:03",
      "content": "<p>I wonder what is your time span to calculate frequency.</p>",
      "votes": null,
      "replies": [
        {
          "id": 269377,
          "author_name": "npa02012",
          "author_url": "",
          "post_date": "01/16/2018 18:04:11",
          "content": "<p>Two step process: <br>\n- Get all item/store combinations between 2017/01/01 and the start of the train cycle. <br>\n- For each item, divide number of appearances by total number of item/store combinations.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 269568,
      "author_name": "cpmpml",
      "author_url": "",
      "post_date": "01/17/2018 02:12:25",
      "content": "<blockquote>\n  <p>knowing which day stores get product for restocking, and potentially Retail Management Software data (i.e. data on when products are being pulled from the backroom) would make prediction a lot easier. </p>\n</blockquote>\n\n<p>Indeed, discussed this in the early days of the competition  in the forum.  Out of stock info in particular would have been great.</p>\n\n<p>Thanks for sharing, and congrats on the result!</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "269274": "The 6th place solution was an ensemble of two solutions that score .517 privately (top 40).  Here is my top 40 solution:  \n  \n##Basic Outline  \n- LGBM Framework which used only 2017 data.\n- Over 500 features.\n- Fairly reliable cross-validation on 07-26 --&gt; 08/10\n  \n## Features\nThese are the most important features. The following order reflects importance; however, by nature of having 16 models, there is no exact order. Unless otherwise noted, this was all done at the item-store level.  \n  \n- ma_median * isd_avg / isd_week_avg - popularized early on in the competition.  \n- ma_median - Coupled with binary for whether or not it is equal to 0.  \n- Day-of-week averages - Different time periods including 7, 14, 28, 56, 112.  \n- Days since appeared - Difference between the 'start date' of the training cycle and the first date the item showed up in the original train file.\n- Quantiles for several different time-spans.  \n- Whether the item will be onpromotion.  \n- Simple averages for different time-spans.  \n- Item-cluster means - The past 5-day mean was a good predictor.  \n- Future promotional 'sums' - E.g: sum of onpromotion 8/16 through 8/18.  \n- mean_no_zero_sales - Mean of instances where unit_sales &gt; 0.  \n- Frequency encoding - calculate the frequency of appearance for items, stores, families and classes (four columns that each sum to 1).  \n    \nThe above predictors consistently showed up as important predictors, or made immediate score advancements. The following predictors definitely helped as a whole:  \n  \n- One-hot-encoding clusters, states, types, cities and families.  \n- Weekend and weekday means.  \n- Staggered mean data (e.g. 8/07 --&gt; 8/14 for the test-set).  \n- Staggered quantile data.  \n- Past number of zero sales for different time-spans.  \n- Past number of promotional days.  \n- Past promotional sales averages.  \n- Past day-of-week quantile data.  \n    \n##Final Submission\nMentioned earlier, this is a top-40 solution on it's own. My teammate, [Eran][1], was scoring similarly. He also used LGBM, but we had quite different Feature Engineering. Specifically, we had different top predictors and we generally used different time-spans. We each ran our models about 5 times and created a final ensemble - the 6th place solution at .514 (.507 public LB).  \n  \n##Some Thoughts\n- This was a supply-demand problem. In a more realistic setting, knowing which days stores get product for restocking, and potentially Retail Management Software data (i.e. data on when products are being pulled from the backroom) would make prediction a lot easier.  \n- I did not worry about the onpromotion bias. The data-set is very complex, and 'filling in the blanks' seemed unrealistic. If an item was on promotion, but had 0 unit_sales, then it either is very low demand or out-of-stock.  \n- The only certain way to know if a new item-store combination is 'real' is if it was on promotion at some point during the test-set days.  \n- Having your model data start from 8/9 and predicting 8-16 --&gt; 8-20 can be useful to see how it will do for the private leader board.  \n- Examining which items were getting predicted poorly in the validation set was very useful for coming up with feature ideas.  \n\n\n\n  [1]: https://www.kaggle.com/eranah",
    "269364": "I wonder what is your time span to calculate frequency.",
    "269377": "Two step process:  \n- Get all item/store combinations between 2017/01/01 and the start of the train cycle.  \n- For each item, divide number of appearances by total number of item/store combinations.",
    "269568": "&gt;  knowing which day stores get product for restocking, and potentially Retail Management Software data (i.e. data on when products are being pulled from the backroom) would make prediction a lot easier. \n\nIndeed, discussed this in the early days of the competition  in the forum.  Out of stock info in particular would have been great.\n\nThanks for sharing, and congrats on the result!"
  },
  "source": "meta"
}