{
  "id": 47582,
  "title": "1st place solution",
  "url": "/competitions/favorita-grocery-sales-forecasting/discussion/47582",
  "author_name": "Eureka",
  "post_date": "2018-01-16T17:20:20.186000",
  "votes": 191,
  "comment_count": 36,
  "views": 0,
  "content": "<p>Congrats to all winner teams and new grandmaster sjv.\nThanks to kaggle for hosting and Favorita for sponsoring this great competition.\nSpecial thanks to @sjv, @senkin13, @tunguz, @ceshine, we build our models based on your kernels.</p>\n\n<ul>\n<li><a href=\"https://github.com/sjvasquez/web-traffic-forecasting/blob/master/cnn.py\">https://github.com/sjvasquez/web-traffic-forecasting/blob/master/cnn.py</a></li>\n<li><a href=\"https://www.kaggle.com/senkin13/lstm-starter/code\">https://www.kaggle.com/senkin13/lstm-starter/code</a></li>\n<li><a href=\"https://www.kaggle.com/tunguz/lgbm-one-step-ahead-lb-0-513\">https://www.kaggle.com/tunguz/lgbm-one-step-ahead-lb-0-513</a> </li>\n<li><a href=\"https://www.kaggle.com/ceshine/lgbm-starter\">https://www.kaggle.com/ceshine/lgbm-starter</a></li>\n</ul>\n\n<p>Like the Rossmann competiton, the private leaderboard shaked up again this time. I think luck is on our side finally.   </p>\n\n<hr>\n\n<h2>Sample Selection</h2>\n\n<p>we used only 2017 data to extract features and construct samples.</p>\n\n<p>train data：20170531 - 20170719 or 20170614 - 20170719， different models are trained with different data set.</p>\n\n<p>validition: 20170726 - 20170810</p>\n\n<p>In fact, we tried to use more data but failed. The gap between public and private leadboard is not very stable. If we train a single model for data of 16 days, the gap will be smaller(0.002-0.003).</p>\n\n<h2>Preprocessing</h2>\n\n<p>We just filled missing or negtive promotion and target values with 0.</p>\n\n<h2>Feature Engineering</h2>\n\n<ol>\n<li>basic features\n<ul><li>category features: store, item, famlily, class, cluster...</li>\n<li>promotion</li>\n<li>dayofweek(only for model 3)</li></ul></li>\n<li>statitical features: we use some methods to stat some targets for different keys in different time windows\n<ul><li>time windows\n<ul><li>nearest days: [1,3,5,7,14,30,60,140]</li>\n<li>equal time windows: [1] * 16, [7] * 20...</li></ul></li>\n<li>key：store x item, item, store x class</li>\n<li>target: promotion, unit_sales, zeros</li>\n<li>method\n<ul><li>mean, median, max, min, std</li>\n<li>days since last appearance</li>\n<li>difference of mean value between adjacent time windows(only for equal time windows)</li></ul></li></ul></li>\n<li>useless features\n<ul><li>holidays</li>\n<li>other keys such as: cluster x item, store x family...</li></ul></li>\n</ol>\n\n<h2>Single Model</h2>\n\n<ul>\n<li>model_1 :  0.506 / 0.511 ,  16 lgb models trained for each day <a href=\"https://www.kaggle.com/shixw125/1st-place-lgb-model-public-0-506-private-0-511\">source code</a> </li>\n<li>model_2 :  0.507 / 0.513 ,  16 nn models trained for each day <a href=\"https://www.kaggle.com/shixw125/1st-place-nn-model-public-0-507-private-0-513\">source code</a></li>\n<li>model_3 :  0.512  / 0.515，1 lgb model for 16 days with almost same features as model_1</li>\n<li>model_4 :  0.517  / 0.519，1 nn model based on @sjv's code</li>\n</ul>\n\n<h2>Ensemble</h2>\n\n<p>Stacking doesn't work well this time, our best model is linear blend of 4 single models.</p>\n\n<p>final submission = 0.42*model_1 + 0.28 * model_2 + 0.18 * model_3 + 0.12 * model_4 </p>\n\n<p>public = 0.504 , private = 0.509</p>",
  "messages": [
    {
      "id": 269355,
      "postDate": "2018-01-16T17:20:20.187Z",
      "content": "<p>Congrats to all winner teams and new grandmaster sjv.\nThanks to kaggle for hosting and Favorita for sponsoring this great competition.\nSpecial thanks to @sjv, @senkin13, @tunguz, @ceshine, we build our models based on your kernels.</p>\n\n<ul>\n<li><a href=\"https://github.com/sjvasquez/web-traffic-forecasting/blob/master/cnn.py\">https://github.com/sjvasquez/web-traffic-forecasting/blob/master/cnn.py</a></li>\n<li><a href=\"https://www.kaggle.com/senkin13/lstm-starter/code\">https://www.kaggle.com/senkin13/lstm-starter/code</a></li>\n<li><a href=\"https://www.kaggle.com/tunguz/lgbm-one-step-ahead-lb-0-513\">https://www.kaggle.com/tunguz/lgbm-one-step-ahead-lb-0-513</a> </li>\n<li><a href=\"https://www.kaggle.com/ceshine/lgbm-starter\">https://www.kaggle.com/ceshine/lgbm-starter</a></li>\n</ul>\n\n<p>Like the Rossmann competiton, the private leaderboard shaked up again this time. I think luck is on our side finally.   </p>\n\n<hr>\n\n<h2>Sample Selection</h2>\n\n<p>we used only 2017 data to extract features and construct samples.</p>\n\n<p>train data：20170531 - 20170719 or 20170614 - 20170719， different models are trained with different data set.</p>\n\n<p>validition: 20170726 - 20170810</p>\n\n<p>In fact, we tried to use more data but failed. The gap between public and private leadboard is not very stable. If we train a single model for data of 16 days, the gap will be smaller(0.002-0.003).</p>\n\n<h2>Preprocessing</h2>\n\n<p>We just filled missing or negtive promotion and target values with 0.</p>\n\n<h2>Feature Engineering</h2>\n\n<ol>\n<li>basic features\n<ul><li>category features: store, item, famlily, class, cluster...</li>\n<li>promotion</li>\n<li>dayofweek(only for model 3)</li></ul></li>\n<li>statitical features: we use some methods to stat some targets for different keys in different time windows\n<ul><li>time windows\n<ul><li>nearest days: [1,3,5,7,14,30,60,140]</li>\n<li>equal time windows: [1] * 16, [7] * 20...</li></ul></li>\n<li>key：store x item, item, store x class</li>\n<li>target: promotion, unit_sales, zeros</li>\n<li>method\n<ul><li>mean, median, max, min, std</li>\n<li>days since last appearance</li>\n<li>difference of mean value between adjacent time windows(only for equal time windows)</li></ul></li></ul></li>\n<li>useless features\n<ul><li>holidays</li>\n<li>other keys such as: cluster x item, store x family...</li></ul></li>\n</ol>\n\n<h2>Single Model</h2>\n\n<ul>\n<li>model_1 :  0.506 / 0.511 ,  16 lgb models trained for each day <a href=\"https://www.kaggle.com/shixw125/1st-place-lgb-model-public-0-506-private-0-511\">source code</a> </li>\n<li>model_2 :  0.507 / 0.513 ,  16 nn models trained for each day <a href=\"https://www.kaggle.com/shixw125/1st-place-nn-model-public-0-507-private-0-513\">source code</a></li>\n<li>model_3 :  0.512  / 0.515，1 lgb model for 16 days with almost same features as model_1</li>\n<li>model_4 :  0.517  / 0.519，1 nn model based on @sjv's code</li>\n</ul>\n\n<h2>Ensemble</h2>\n\n<p>Stacking doesn't work well this time, our best model is linear blend of 4 single models.</p>\n\n<p>final submission = 0.42*model_1 + 0.28 * model_2 + 0.18 * model_3 + 0.12 * model_4 </p>\n\n<p>public = 0.504 , private = 0.509</p>",
      "rawMarkdown": "Congrats to all winner teams and new grandmaster sjv.\nThanks to kaggle for hosting and Favorita for sponsoring this great competition.\nSpecial thanks to @sjv, @senkin13, @tunguz, @ceshine, we build our models based on your kernels.\n\n- https://github.com/sjvasquez/web-traffic-forecasting/blob/master/cnn.py\n- https://www.kaggle.com/senkin13/lstm-starter/code\n- https://www.kaggle.com/tunguz/lgbm-one-step-ahead-lb-0-513 \n- https://www.kaggle.com/ceshine/lgbm-starter\n\nLike the Rossmann competiton, the private leaderboard shaked up again this time. I think luck is on our side finally.   \n\n------\n## Sample Selection\n\nwe used only 2017 data to extract features and construct samples.\n\ntrain data：20170531 - 20170719 or 20170614 - 20170719， different models are trained with different data set.\n\nvalidition: 20170726 - 20170810\n\nIn fact, we tried to use more data but failed. The gap between public and private leadboard is not very stable. If we train a single model for data of 16 days, the gap will be smaller(0.002-0.003).\n\n## Preprocessing\n\nWe just filled missing or negtive promotion and target values with 0.\n\n## Feature Engineering\n\n1. basic features\n    - category features: store, item, famlily, class, cluster...\n    - promotion\n    - dayofweek(only for model 3)\n2. statitical features: we use some methods to stat some targets for different keys in different time windows\n    - time windows\n        - nearest days: [1,3,5,7,14,30,60,140]\n        - equal time windows: [1] * 16, [7] * 20...\n    - key：store x item, item, store x class\n    - target: promotion, unit_sales, zeros\n    - method\n        * mean, median, max, min, std\n        * days since last appearance\n        * difference of mean value between adjacent time windows(only for equal time windows)\n3. useless features\n    - holidays\n    - other keys such as: cluster x item, store x family...\n    \n## Single Model\n\n-  model_1 :  0.506 / 0.511 ,  16 lgb models trained for each day [source code](https://www.kaggle.com/shixw125/1st-place-lgb-model-public-0-506-private-0-511) \n- model_2 :  0.507 / 0.513 ,  16 nn models trained for each day [source code](https://www.kaggle.com/shixw125/1st-place-nn-model-public-0-507-private-0-513)\n- model_3 :  0.512  / 0.515，1 lgb model for 16 days with almost same features as model_1\n- model_4 :  0.517  / 0.519，1 nn model based on @sjv's code\n\n## Ensemble\n\nStacking doesn't work well this time, our best model is linear blend of 4 single models.\n\nfinal submission = 0.42*model_1 + 0.28 * model_2 + 0.18 * model_3 + 0.12 * model_4 \n\npublic = 0.504 , private = 0.509\n\n",
      "votes": 191
    },
    {
      "id": 556168,
      "postDate": "2019-06-19T23:16:39.710Z",
      "content": "<p>Is there anybody who knows where to find the codes of 1st place solution?</p>",
      "rawMarkdown": "Is there anybody who knows where to find the codes of 1st place solution?",
      "votes": 5
    },
    {
      "id": 269357,
      "postDate": "2018-01-16T17:23:36.853Z",
      "content": "<p>Thanks for sharing!  And congrats on winning the competition.  You say luck, but it is also due to this: We just filled missing or negtive promotion and target values with 0.</p>",
      "rawMarkdown": "Thanks for sharing!  And congrats on winning the competition.  You say luck, but it is also due to this: We just filled missing or negtive promotion and target values with 0.",
      "votes": 18,
      "replies": [
        {
          "id": 269392,
          "postDate": "2018-01-16T18:34:12.270Z",
          "content": "<p>Downvoted?  LOL.  </p>\n\n<p>I bet that we can get a very strong correlation between how team performance evolved between public and private LB, and how they dealt with onpromotion for missing 0 sales rows in train.  </p>\n\n<p>Again, a fact hard to cope with for my courageous and anonymous downvoting friends here ;)</p>",
          "rawMarkdown": "Downvoted?  LOL.  \n\nI bet that we can get a very strong correlation between how team performance evolved between public and private LB, and how they dealt with onpromotion for missing 0 sales rows in train.  \n\nAgain, a fact hard to cope with for my courageous and anonymous downvoting friends here ;)",
          "votes": 9
        }
      ]
    },
    {
      "id": 276049,
      "postDate": "2018-01-30T15:45:56.533Z",
      "content": "<p>Nice solutions. One question. After validation, why not combine validation data and training data together after validation, so that we can have more training data for final testing?</p>",
      "rawMarkdown": "Nice solutions. One question. After validation, why not combine validation data and training data together after validation, so that we can have more training data for final testing?",
      "votes": 6
    },
    {
      "id": 269531,
      "postDate": "2018-01-17T00:58:45.793Z",
      "content": "<p>I'd tried LSTM-256, Densen512-256-64, not success.Finally , I haven't use LSTM model.\nYour team is very great!</p>",
      "rawMarkdown": "I'd tried LSTM-256, Densen512-256-64, not success.Finally , I haven't use LSTM model.\nYour team is very great!",
      "votes": 1
    },
    {
      "id": 269474,
      "postDate": "2018-01-16T22:23:23.873Z",
      "content": "<p>That's a cray batch size (65K).\nSubtracting the mean is also a good trick, i'd tried it but didn't get anything better.</p>",
      "rawMarkdown": "That's a cray batch size (65K).\nSubtracting the mean is also a good trick, i'd tried it but didn't get anything better.",
      "votes": 1
    },
    {
      "id": 270004,
      "postDate": "2018-01-17T16:40:09.950Z",
      "content": "<blockquote>\n  <p>We just filled missing or negtive promotion and target values with 0.</p>\n</blockquote>\n\n<p>@Eureka: by looking at your shared lgb code <a href=\"https://www.kaggle.com/shixw125/1st-place-lgb-model-public-0-506-private-0-511\">https://www.kaggle.com/shixw125/1st-place-lgb-model-public-0-506-private-0-511</a>, in particular, line 49-51, as below, it seems that you didn't filled the missing or negative missing promotion with 0. Did I miss anything here? Btw, congratulation for the winning!</p>\n\n<p>promo_2017_train = df_2017.set_index(\n    [\"store_nbr\", \"item_nbr\", \"date\"])[[\"onpromotion\"]].unstack(\n        level=-1).fillna(False)</p>",
      "rawMarkdown": "&gt; We just filled missing or negtive promotion and target values with 0.\n\n@Eureka: by looking at your shared lgb code https://www.kaggle.com/shixw125/1st-place-lgb-model-public-0-506-private-0-511, in particular, line 49-51, as below, it seems that you didn't filled the missing or negative missing promotion with 0. Did I miss anything here? Btw, congratulation for the winning!\n\npromo_2017_train = df_2017.set_index(\n    [\"store_nbr\", \"item_nbr\", \"date\"])[[\"onpromotion\"]].unstack(\n        level=-1).fillna(False)\n\n",
      "votes": 2,
      "replies": [
        {
          "id": 270077,
          "postDate": "2018-01-17T18:14:03.173Z",
          "content": "<p>Looks to me they fill with False, which is more or less the same as 0...</p>",
          "rawMarkdown": "Looks to me they fill with False, which is more or less the same as 0...",
          "votes": -1
        },
        {
          "id": 270086,
          "postDate": "2018-01-17T18:36:39.690Z",
          "content": "<p>@CPMP: But it didn't address \"fill negative missing promotion with 0\". </p>\n\n<p>Also, if the promotion preprocessing is just sth like promo_2017_train = df_2017.set_index( [\"store_nbr\", \"item_nbr\", \"date\"])[[\"onpromotion\"]].unstack( level=-1).fillna(False), then this actually has already been included in those popular lgb starter scripts like this <a href=\"https://www.kaggle.com/ceshine/lgbm-starter\">https://www.kaggle.com/ceshine/lgbm-starter</a> or this <a href=\"https://www.kaggle.com/tunguz/lgbm-one-step-ahead-c8de0f\">https://www.kaggle.com/tunguz/lgbm-one-step-ahead-c8de0f</a>, and thus  I guess that most competitors who used the lgb starter script were also using same \".fillna(False)\"  preprocessing for promotion.  I also have applied such \".fillna(False)\" for promotion variable (since I used the shared lgb starter script as my starting point).  </p>\n\n<p>Therefore, such processing on promotion should not be a factor to explain the significant difference in pub-private  ranking for competitors, given how popular these lgb starter scripts are.</p>",
          "rawMarkdown": "@CPMP: But it didn't address \"fill negative missing promotion with 0\". \n\nAlso, if the promotion preprocessing is just sth like promo_2017_train = df_2017.set_index( [\"store_nbr\", \"item_nbr\", \"date\"])[[\"onpromotion\"]].unstack( level=-1).fillna(False), then this actually has already been included in those popular lgb starter scripts like this https://www.kaggle.com/ceshine/lgbm-starter or this https://www.kaggle.com/tunguz/lgbm-one-step-ahead-c8de0f, and thus  I guess that most competitors who used the lgb starter script were also using same \".fillna(False)\"  preprocessing for promotion.  I also have applied such \".fillna(False)\" for promotion variable (since I used the shared lgb starter script as my starting point).  \n\nTherefore, such processing on promotion should not be a factor to explain the significant difference in pub-private  ranking for competitors, given how popular these lgb starter scripts are.",
          "votes": 3
        },
        {
          "id": 270357,
          "postDate": "2018-01-18T05:59:34.587Z",
          "content": "<p>@ Shize: We filled negative or missing target with 0 and filled missing promotion with \"false\" (the same as 0). As you have noticed, this preprocessing is the same as Ceshine's LGBM starter script (public: 0.514, private: 0.522). But based on Ceshine's kernel, we added similar stats features of item_nbr, it turned out that the gap between public and private decreased from 0.008 to 0.004 (public: 0.512, private: 0.516). Then we added more features, the gap is always between 0.002-0.004 (only one model's gap is 0.005, public: 0.506, private: 0.511). I still don't understand why there is a big gap between your public and private scores, maybe we have some luck ^_^</p>",
          "rawMarkdown": "@ Shize: We filled negative or missing target with 0 and filled missing promotion with \"false\" (the same as 0). As you have noticed, this preprocessing is the same as Ceshine's LGBM starter script (public: 0.514, private: 0.522). But based on Ceshine's kernel, we added similar stats features of item_nbr, it turned out that the gap between public and private decreased from 0.008 to 0.004 (public: 0.512, private: 0.516). Then we added more features, the gap is always between 0.002-0.004 (only one model's gap is 0.005, public: 0.506, private: 0.511). I still don't understand why there is a big gap between your public and private scores, maybe we have some luck ^_^",
          "votes": 2
        },
        {
          "id": 270416,
          "postDate": "2018-01-18T07:36:33.220Z",
          "content": "<p>@Shize, yes, most of top 10 teams used the simple <em>0 sales no promotion</em>.  But other teams tried something different, and it backfired at them.  They are unhappy about it, see the threads below. </p>\n\n<p><a href=\"https://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47529\">https://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47529</a></p>\n\n<p><a href=\"https://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47562\">https://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47562</a></p>\n\n<p><a href=\"https://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47564#269183\">https://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47564#269183</a></p>\n\n<p>This said, it is not what explains why you dropped in LB given, you used the same simple preprocessing.  Not sure why you dropped, I thought it was item_nbr, but w team did use it and they are ahead.</p>",
          "rawMarkdown": "@Shize, yes, most of top 10 teams used the simple *0 sales no promotion*.  But other teams tried something different, and it backfired at them.  They are unhappy about it, see the threads below. \n\nhttps://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47529\n\nhttps://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47562\n\nhttps://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47564#269183\n\nThis said, it is not what explains why you dropped in LB given, you used the same simple preprocessing.  Not sure why you dropped, I thought it was item_nbr, but w team did use it and they are ahead.\n\n"
        }
      ]
    },
    {
      "id": 269558,
      "postDate": "2018-01-17T01:47:16.510Z",
      "content": "<p>Congrats.Thanks for sharing.It seems I missed \"days since last appearance\".</p>",
      "rawMarkdown": "Congrats.Thanks for sharing.It seems I missed \"days since last appearance\"."
    },
    {
      "id": 269361,
      "postDate": "2018-01-16T17:32:10.247Z",
      "content": "<p>Congrats Eureka on winning and thanks for sharing some code. That allows newbies like me to learn a lot!</p>",
      "rawMarkdown": "Congrats Eureka on winning and thanks for sharing some code. That allows newbies like me to learn a lot!"
    },
    {
      "id": 3082441,
      "postDate": "2024-12-28T07:10:52.817Z",
      "content": "<p>Nice solutions. One question. After validation, why not combine validation data and training data together after validation, so that we can have more training data for final testing?</p>",
      "rawMarkdown": "Nice solutions. One question. After validation, why not combine validation data and training data together after validation, so that we can have more training data for final testing?"
    },
    {
      "id": 605356,
      "postDate": "2019-08-22T09:33:53.857Z",
      "content": "<p>somebody could tell me where I can find the 3th model code?🙏 </p>",
      "rawMarkdown": "somebody could tell me where I can find the 3th model code?🙏 "
    },
    {
      "id": 556169,
      "postDate": "2019-06-19T23:19:19.313Z",
      "content": "<p>Is there anybody knows where to find 1st place codes?</p>",
      "rawMarkdown": "Is there anybody knows where to find 1st place codes?",
      "replies": [
        {
          "id": 566454,
          "postDate": "2019-07-02T07:25:35.690Z",
          "content": "<p>You can search in \"Single Model\" section in post, there you will find github link.</p>",
          "rawMarkdown": "You can search in \"Single Model\" section in post, there you will find github link."
        },
        {
          "id": 604455,
          "postDate": "2019-08-21T12:07:43.703Z",
          "content": "<p>I just want to know where I can get the 3th model and the 4th model? I just can't find the single model</p>",
          "rawMarkdown": "I just want to know where I can get the 3th model and the 4th model? I just can't find the single model"
        },
        {
          "id": 624704,
          "postDate": "2019-09-12T09:49:39.833Z",
          "content": "<p>I think exact code file is not there. As a workaround, you can remove the last loop for modelling and try to use \"label=y_train\" instead of \"label=y_train[:, i]\". Same needs to be done for validation data as well.\nAlmost done, don't know if more changes missed by me here. But it will be clearer as you implement.</p>",
          "rawMarkdown": "I think exact code file is not there. As a workaround, you can remove the last loop for modelling and try to use \"label=y_train\" instead of \"label=y_train[:, i]\". Same needs to be done for validation data as well.\nAlmost done, don't know if more changes missed by me here. But it will be clearer as you implement."
        }
      ]
    },
    {
      "id": 360306,
      "postDate": "2018-07-22T05:57:00.383Z",
      "content": "<p>Anybody share the features importance ranking?</p>",
      "rawMarkdown": "Anybody share the features importance ranking?"
    },
    {
      "id": 327677,
      "postDate": "2018-05-12T06:48:12.747Z",
      "content": "<p>Keep in step with Eureka.</p>",
      "rawMarkdown": "Keep in step with Eureka."
    },
    {
      "id": 280709,
      "postDate": "2018-02-10T18:13:48.263Z",
      "content": "<p>Thanks for the work. interesting feature engineering.</p>",
      "rawMarkdown": "Thanks for the work. interesting feature engineering."
    },
    {
      "id": 276656,
      "postDate": "2018-02-01T03:45:07.683Z",
      "content": "<p>great work</p>",
      "rawMarkdown": "great work"
    },
    {
      "id": 271693,
      "postDate": "2018-01-21T06:42:07.307Z",
      "content": "<p>First, congrats. Then, I am interested in how did you do the cross-validation on the time-series data? Thanks.</p>",
      "rawMarkdown": "First, congrats. Then, I am interested in how did you do the cross-validation on the time-series data? Thanks."
    },
    {
      "id": 270586,
      "postDate": "2018-01-18T14:58:28.707Z",
      "content": "<p>Congratulations. Thank you for taking the time to share and explain your approach. </p>",
      "rawMarkdown": "Congratulations. Thank you for taking the time to share and explain your approach. "
    },
    {
      "id": 270052,
      "postDate": "2018-01-17T17:39:27.847Z",
      "content": "<p>Very brilliant!</p>",
      "rawMarkdown": "Very brilliant!"
    },
    {
      "id": 269858,
      "postDate": "2018-01-17T12:15:55.740Z",
      "content": "<p>Congratulations!</p>",
      "rawMarkdown": "Congratulations!"
    },
    {
      "id": 269724,
      "postDate": "2018-01-17T07:08:38.007Z",
      "content": "<p>Thanks for this sharing. I want to know how do you decide the weight(0.42 0.28 0.18 0.12) in the ensemble ? </p>",
      "rawMarkdown": "Thanks for this sharing. I want to know how do you decide the weight(0.42 0.28 0.18 0.12) in the ensemble ? ",
      "replies": [
        {
          "id": 269755,
          "postDate": "2018-01-17T08:18:31.557Z",
          "content": "<p>In fact , we did a two-stage linear blending and all weights are decided based on both cv and public score. <br>\nsubmission = 0.7 * (0.6 model_1 + 0.4 model_2) + 0.3 * ( 0.6 model_3 + 0.4 model_4)</p>",
          "rawMarkdown": "In fact , we did a two-stage linear blending and all weights are decided based on both cv and public score.  \nsubmission = 0.7 * (0.6 model_1 + 0.4 model_2) + 0.3 * ( 0.6 model_3 + 0.4 model_4)",
          "votes": 5
        },
        {
          "id": 269764,
          "postDate": "2018-01-17T08:50:14.003Z",
          "content": "<p>Thank you!  Beginner learned two-stage linear blending here !</p>",
          "rawMarkdown": "Thank you!  Beginner learned two-stage linear blending here !"
        },
        {
          "id": 271363,
          "postDate": "2018-01-20T09:26:32.873Z",
          "content": "<p>Could you explain how to do that, or just post the reference to the technique.</p>",
          "rawMarkdown": "Could you explain how to do that, or just post the reference to the technique.",
          "votes": 5
        }
      ]
    },
    {
      "id": 269735,
      "postDate": "2018-01-17T07:31:16.253Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 534266,
      "postDate": "2019-05-21T02:11:53.633Z",
      "content": "<p>Congrats and Thanks for Sharing</p>",
      "rawMarkdown": "Congrats and Thanks for Sharing",
      "votes": 1
    },
    {
      "id": 271041,
      "postDate": "2018-01-19T15:16:21.007Z",
      "content": "<p>Thanks for sharing! </p>",
      "rawMarkdown": "Thanks for sharing! "
    },
    {
      "id": 270215,
      "postDate": "2018-01-17T23:11:43.687Z",
      "content": "<p>Thanks for sharing! :) And congrats!!!</p>",
      "rawMarkdown": "Thanks for sharing! :) And congrats!!!"
    },
    {
      "id": 269612,
      "postDate": "2018-01-17T02:59:50.110Z",
      "content": "<p>Congrats.Thanks for sharing</p>",
      "rawMarkdown": "Congrats.Thanks for sharing"
    }
  ],
  "comments": [
    {
      "id": 556168,
      "author_name": "Mehdi Ranjbar",
      "author_url": "",
      "post_date": "2019-06-19T23:16:39.710000",
      "content": "<p>Is there anybody who knows where to find the codes of 1st place solution?</p>",
      "votes": 5,
      "replies": []
    },
    {
      "id": 269357,
      "author_name": "CPMP",
      "author_url": "",
      "post_date": "2018-01-16T17:23:36.853000",
      "content": "<p>Thanks for sharing!  And congrats on winning the competition.  You say luck, but it is also due to this: We just filled missing or negtive promotion and target values with 0.</p>",
      "votes": 18,
      "replies": [
        {
          "id": 269392,
          "author_name": "CPMP",
          "author_url": "",
          "post_date": "2018-01-16T18:34:12.270000",
          "content": "<p>Downvoted?  LOL.  </p>\n\n<p>I bet that we can get a very strong correlation between how team performance evolved between public and private LB, and how they dealt with onpromotion for missing 0 sales rows in train.  </p>\n\n<p>Again, a fact hard to cope with for my courageous and anonymous downvoting friends here ;)</p>",
          "votes": 9,
          "replies": []
        }
      ]
    },
    {
      "id": 276049,
      "author_name": "LongYin/杰少",
      "author_url": "",
      "post_date": "2018-01-30T15:45:56.533000",
      "content": "<p>Nice solutions. One question. After validation, why not combine validation data and training data together after validation, so that we can have more training data for final testing?</p>",
      "votes": 6,
      "replies": []
    },
    {
      "id": 269531,
      "author_name": "yyll008",
      "author_url": "",
      "post_date": "2018-01-17T00:58:45.793000",
      "content": "<p>I'd tried LSTM-256, Densen512-256-64, not success.Finally , I haven't use LSTM model.\nYour team is very great!</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 269474,
      "author_name": "Dan Ofer",
      "author_url": "",
      "post_date": "2018-01-16T22:23:23.873000",
      "content": "<p>That's a cray batch size (65K).\nSubtracting the mean is also a good trick, i'd tried it but didn't get anything better.</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 270004,
      "author_name": "Shize Su",
      "author_url": "",
      "post_date": "2018-01-17T16:40:09.950000",
      "content": "<blockquote>\n  <p>We just filled missing or negtive promotion and target values with 0.</p>\n</blockquote>\n\n<p>@Eureka: by looking at your shared lgb code <a href=\"https://www.kaggle.com/shixw125/1st-place-lgb-model-public-0-506-private-0-511\">https://www.kaggle.com/shixw125/1st-place-lgb-model-public-0-506-private-0-511</a>, in particular, line 49-51, as below, it seems that you didn't filled the missing or negative missing promotion with 0. Did I miss anything here? Btw, congratulation for the winning!</p>\n\n<p>promo_2017_train = df_2017.set_index(\n    [\"store_nbr\", \"item_nbr\", \"date\"])[[\"onpromotion\"]].unstack(\n        level=-1).fillna(False)</p>",
      "votes": 2,
      "replies": [
        {
          "id": 270077,
          "author_name": "CPMP",
          "author_url": "",
          "post_date": "2018-01-17T18:14:03.173000",
          "content": "<p>Looks to me they fill with False, which is more or less the same as 0...</p>",
          "votes": -1,
          "replies": []
        },
        {
          "id": 270086,
          "author_name": "Shize Su",
          "author_url": "",
          "post_date": "2018-01-17T18:36:39.690000",
          "content": "<p>@CPMP: But it didn't address \"fill negative missing promotion with 0\". </p>\n\n<p>Also, if the promotion preprocessing is just sth like promo_2017_train = df_2017.set_index( [\"store_nbr\", \"item_nbr\", \"date\"])[[\"onpromotion\"]].unstack( level=-1).fillna(False), then this actually has already been included in those popular lgb starter scripts like this <a href=\"https://www.kaggle.com/ceshine/lgbm-starter\">https://www.kaggle.com/ceshine/lgbm-starter</a> or this <a href=\"https://www.kaggle.com/tunguz/lgbm-one-step-ahead-c8de0f\">https://www.kaggle.com/tunguz/lgbm-one-step-ahead-c8de0f</a>, and thus  I guess that most competitors who used the lgb starter script were also using same \".fillna(False)\"  preprocessing for promotion.  I also have applied such \".fillna(False)\" for promotion variable (since I used the shared lgb starter script as my starting point).  </p>\n\n<p>Therefore, such processing on promotion should not be a factor to explain the significant difference in pub-private  ranking for competitors, given how popular these lgb starter scripts are.</p>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 270357,
          "author_name": "weiwei",
          "author_url": "",
          "post_date": "2018-01-18T05:59:34.587000",
          "content": "<p>@ Shize: We filled negative or missing target with 0 and filled missing promotion with \"false\" (the same as 0). As you have noticed, this preprocessing is the same as Ceshine's LGBM starter script (public: 0.514, private: 0.522). But based on Ceshine's kernel, we added similar stats features of item_nbr, it turned out that the gap between public and private decreased from 0.008 to 0.004 (public: 0.512, private: 0.516). Then we added more features, the gap is always between 0.002-0.004 (only one model's gap is 0.005, public: 0.506, private: 0.511). I still don't understand why there is a big gap between your public and private scores, maybe we have some luck ^_^</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 270416,
          "author_name": "CPMP",
          "author_url": "",
          "post_date": "2018-01-18T07:36:33.220000",
          "content": "<p>@Shize, yes, most of top 10 teams used the simple <em>0 sales no promotion</em>.  But other teams tried something different, and it backfired at them.  They are unhappy about it, see the threads below. </p>\n\n<p><a href=\"https://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47529\">https://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47529</a></p>\n\n<p><a href=\"https://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47562\">https://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47562</a></p>\n\n<p><a href=\"https://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47564#269183\">https://www.kaggle.com/c/favorita-grocery-sales-forecasting/discussion/47564#269183</a></p>\n\n<p>This said, it is not what explains why you dropped in LB given, you used the same simple preprocessing.  Not sure why you dropped, I thought it was item_nbr, but w team did use it and they are ahead.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 269558,
      "author_name": "plantsgo",
      "author_url": "",
      "post_date": "2018-01-17T01:47:16.510000",
      "content": "<p>Congrats.Thanks for sharing.It seems I missed \"days since last appearance\".</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 269361,
      "author_name": "FabSchreiber",
      "author_url": "",
      "post_date": "2018-01-16T17:32:10.247000",
      "content": "<p>Congrats Eureka on winning and thanks for sharing some code. That allows newbies like me to learn a lot!</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 3082441,
      "author_name": "HuangdaxianZach",
      "author_url": "",
      "post_date": "2024-12-28T07:10:52.817000",
      "content": "<p>Nice solutions. One question. After validation, why not combine validation data and training data together after validation, so that we can have more training data for final testing?</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 605356,
      "author_name": "Dou Fan",
      "author_url": "",
      "post_date": "2019-08-22T09:33:53.857000",
      "content": "<p>somebody could tell me where I can find the 3th model code?🙏 </p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 556169,
      "author_name": "Mehdi Ranjbar",
      "author_url": "",
      "post_date": "2019-06-19T23:19:19.313000",
      "content": "<p>Is there anybody knows where to find 1st place codes?</p>",
      "votes": 0,
      "replies": [
        {
          "id": 566454,
          "author_name": "generalizer",
          "author_url": "",
          "post_date": "2019-07-02T07:25:35.690000",
          "content": "<p>You can search in \"Single Model\" section in post, there you will find github link.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 604455,
          "author_name": "Dou Fan",
          "author_url": "",
          "post_date": "2019-08-21T12:07:43.703000",
          "content": "<p>I just want to know where I can get the 3th model and the 4th model? I just can't find the single model</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 624704,
          "author_name": "generalizer",
          "author_url": "",
          "post_date": "2019-09-12T09:49:39.833000",
          "content": "<p>I think exact code file is not there. As a workaround, you can remove the last loop for modelling and try to use \"label=y_train\" instead of \"label=y_train[:, i]\". Same needs to be done for validation data as well.\nAlmost done, don't know if more changes missed by me here. But it will be clearer as you implement.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 360306,
      "author_name": "lvty",
      "author_url": "",
      "post_date": "2018-07-22T05:57:00.383000",
      "content": "<p>Anybody share the features importance ranking?</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 327677,
      "author_name": "Louis Green",
      "author_url": "",
      "post_date": "2018-05-12T06:48:12.747000",
      "content": "<p>Keep in step with Eureka.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 280709,
      "author_name": "YAD",
      "author_url": "",
      "post_date": "2018-02-10T18:13:48.263000",
      "content": "<p>Thanks for the work. interesting feature engineering.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 276656,
      "author_name": "zkjjj",
      "author_url": "",
      "post_date": "2018-02-01T03:45:07.683000",
      "content": "<p>great work</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 271693,
      "author_name": "RuiLa",
      "author_url": "",
      "post_date": "2018-01-21T06:42:07.307000",
      "content": "<p>First, congrats. Then, I am interested in how did you do the cross-validation on the time-series data? Thanks.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 270586,
      "author_name": "Alberto Artasanchez",
      "author_url": "",
      "post_date": "2018-01-18T14:58:28.707000",
      "content": "<p>Congratulations. Thank you for taking the time to share and explain your approach. </p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 270052,
      "author_name": "li",
      "author_url": "",
      "post_date": "2018-01-17T17:39:27.847000",
      "content": "<p>Very brilliant!</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 269858,
      "author_name": "Pepe Bawagan",
      "author_url": "",
      "post_date": "2018-01-17T12:15:55.740000",
      "content": "<p>Congratulations!</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 269724,
      "author_name": "yyqing",
      "author_url": "",
      "post_date": "2018-01-17T07:08:38.007000",
      "content": "<p>Thanks for this sharing. I want to know how do you decide the weight(0.42 0.28 0.18 0.12) in the ensemble ? </p>",
      "votes": 0,
      "replies": [
        {
          "id": 269755,
          "author_name": "Eureka",
          "author_url": "",
          "post_date": "2018-01-17T08:18:31.557000",
          "content": "<p>In fact , we did a two-stage linear blending and all weights are decided based on both cv and public score. <br>\nsubmission = 0.7 * (0.6 model_1 + 0.4 model_2) + 0.3 * ( 0.6 model_3 + 0.4 model_4)</p>",
          "votes": 5,
          "replies": []
        },
        {
          "id": 269764,
          "author_name": "yyqing",
          "author_url": "",
          "post_date": "2018-01-17T08:50:14.003000",
          "content": "<p>Thank you!  Beginner learned two-stage linear blending here !</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 271363,
          "author_name": "K Lin",
          "author_url": "",
          "post_date": "2018-01-20T09:26:32.873000",
          "content": "<p>Could you explain how to do that, or just post the reference to the technique.</p>",
          "votes": 5,
          "replies": []
        }
      ]
    },
    {
      "id": 269735,
      "author_name": "",
      "author_url": "",
      "post_date": "2018-01-17T07:31:16.253000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 534266,
      "author_name": "Jayachander Reddy",
      "author_url": "",
      "post_date": "2019-05-21T02:11:53.633000",
      "content": "<p>Congrats and Thanks for Sharing</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 271041,
      "author_name": "Chen Shen",
      "author_url": "",
      "post_date": "2018-01-19T15:16:21.007000",
      "content": "<p>Thanks for sharing! </p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 270215,
      "author_name": "marielgh",
      "author_url": "",
      "post_date": "2018-01-17T23:11:43.687000",
      "content": "<p>Thanks for sharing! :) And congrats!!!</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 269612,
      "author_name": "THLUO",
      "author_url": "",
      "post_date": "2018-01-17T02:59:50.110000",
      "content": "<p>Congrats.Thanks for sharing</p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "269355": "Congrats to all winner teams and new grandmaster sjv.\nThanks to kaggle for hosting and Favorita for sponsoring this great competition.\nSpecial thanks to @sjv, @senkin13, @tunguz, @ceshine, we build our models based on your kernels.\n\n- https://github.com/sjvasquez/web-traffic-forecasting/blob/master/cnn.py\n- https://www.kaggle.com/senkin13/lstm-starter/code\n- https://www.kaggle.com/tunguz/lgbm-one-step-ahead-lb-0-513 \n- https://www.kaggle.com/ceshine/lgbm-starter\n\nLike the Rossmann competiton, the private leaderboard shaked up again this time. I think luck is on our side finally.   \n\n------\n## Sample Selection\n\nwe used only 2017 data to extract features and construct samples.\n\ntrain data：20170531 - 20170719 or 20170614 - 20170719， different models are trained with different data set.\n\nvalidition: 20170726 - 20170810\n\nIn fact, we tried to use more data but failed. The gap between public and private leadboard is not very stable. If we train a single model for data of 16 days, the gap will be smaller(0.002-0.003).\n\n## Preprocessing\n\nWe just filled missing or negtive promotion and target values with 0.\n\n## Feature Engineering\n\n1. basic features\n    - category features: store, item, famlily, class, cluster...\n    - promotion\n    - dayofweek(only for model 3)\n2. statitical features: we use some methods to stat some targets for different keys in different time windows\n    - time windows\n        - nearest days: [1,3,5,7,14,30,60,140]\n        - equal time windows: [1] * 16, [7] * 20...\n    - key：store x item, item, store x class\n    - target: promotion, unit_sales, zeros\n    - method\n        * mean, median, max, min, std\n        * days since last appearance\n        * difference of mean value between adjacent time windows(only for equal time windows)\n3. useless features\n    - holidays\n    - other keys such as: cluster x item, store x family...\n    \n## Single Model\n\n-  model_1 :  0.506 / 0.511 ,  16 lgb models trained for each day [source code](https://www.kaggle.com/shixw125/1st-place-lgb-model-public-0-506-private-0-511) \n- model_2 :  0.507 / 0.513 ,  16 nn models trained for each day [source code](https://www.kaggle.com/shixw125/1st-place-nn-model-public-0-507-private-0-513)\n- model_3 :  0.512  / 0.515，1 lgb model for 16 days with almost same features as model_1\n- model_4 :  0.517  / 0.519，1 nn model based on @sjv's code\n\n## Ensemble\n\nStacking doesn't work well this time, our best model is linear blend of 4 single models.\n\nfinal submission = 0.42*model_1 + 0.28 * model_2 + 0.18 * model_3 + 0.12 * model_4 \n\npublic = 0.504 , private = 0.509\n\n",
    "556168": "Is there anybody who knows where to find the codes of 1st place solution?",
    "269357": "Thanks for sharing!  And congrats on winning the competition.  You say luck, but it is also due to this: We just filled missing or negtive promotion and target values with 0.",
    "276049": "Nice solutions. One question. After validation, why not combine validation data and training data together after validation, so that we can have more training data for final testing?",
    "269531": "I'd tried LSTM-256, Densen512-256-64, not success.Finally , I haven't use LSTM model.\nYour team is very great!",
    "269474": "That's a cray batch size (65K).\nSubtracting the mean is also a good trick, i'd tried it but didn't get anything better.",
    "270004": "&gt; We just filled missing or negtive promotion and target values with 0.\n\n@Eureka: by looking at your shared lgb code https://www.kaggle.com/shixw125/1st-place-lgb-model-public-0-506-private-0-511, in particular, line 49-51, as below, it seems that you didn't filled the missing or negative missing promotion with 0. Did I miss anything here? Btw, congratulation for the winning!\n\npromo_2017_train = df_2017.set_index(\n    [\"store_nbr\", \"item_nbr\", \"date\"])[[\"onpromotion\"]].unstack(\n        level=-1).fillna(False)\n\n",
    "269558": "Congrats.Thanks for sharing.It seems I missed \"days since last appearance\".",
    "269361": "Congrats Eureka on winning and thanks for sharing some code. That allows newbies like me to learn a lot!",
    "3082441": "Nice solutions. One question. After validation, why not combine validation data and training data together after validation, so that we can have more training data for final testing?",
    "605356": "somebody could tell me where I can find the 3th model code?🙏 ",
    "556169": "Is there anybody knows where to find 1st place codes?",
    "360306": "Anybody share the features importance ranking?",
    "327677": "Keep in step with Eureka.",
    "280709": "Thanks for the work. interesting feature engineering.",
    "276656": "great work",
    "271693": "First, congrats. Then, I am interested in how did you do the cross-validation on the time-series data? Thanks.",
    "270586": "Congratulations. Thank you for taking the time to share and explain your approach. ",
    "270052": "Very brilliant!",
    "269858": "Congratulations!",
    "269724": "Thanks for this sharing. I want to know how do you decide the weight(0.42 0.28 0.18 0.12) in the ensemble ? ",
    "269735": "",
    "534266": "Congrats and Thanks for Sharing",
    "271041": "Thanks for sharing! ",
    "270215": "Thanks for sharing! :) And congrats!!!",
    "269612": "Congrats.Thanks for sharing"
  }
}