{
  "id": 47534,
  "title": "My approach - public 0.507, private 0.517",
  "content": "<p><img src=\"http://imglf5.nosdn.127.net/img/OEUzbU5jenB4YlRsQWNNcnk3Um5DVnFkc0Y0eEQyMFQzRXRlRXRBWW5NakMyU28yQnc4MS9nPT0.jpeg?imageView&amp;thumbnail=2086y226&amp;type=jpg&amp;quality=96&amp;stripmeta=0&amp;type=jpg\" alt=\"dd\"></p>\n<h1>Models</h1>\n<p>I use two models to solve this problem</p>\n<ol>\n<li><p>LightGBM, it's based on Ceshine lee's script, but I add some other new features.<br>\na) zero crossing rate (<a href=\"https://en.wikipedia.org/wiki/Zero-crossing_rate)\" target=\"_blank\">https://en.wikipedia.org/wiki/Zero-crossing_rate)</a>, I create this feature for different windows(1, 3, 7, 14, 30, 60) and levels(item level, store*family level)<br>\nbelow is my implementation  </p>\n<p>def corss_zero(row):<br>\n      return (((row[:-1] * row[1:]) == 0) * ~(row[:-1] == row[1:])).sum()</p></li>\n</ol>\n<p>b) zero-sales counts in different windows  </p>\n<pre><code>:  == 0)  \n    :  == 0)  \n    :  == 0) \n</code></pre>\n<p>b) lastest promo day in last 30 days  </p>\n<pre><code> fo_in_row(row):  \n =   \n i in row:  \n     +=   \n     i == :  \n         j  \n -  \n</code></pre>\n<p>\"lastest_promo_30\": get_timespan(promo_2017, t2017, 30, 30).apply(lambda row: fo_in_row(row[::-1]), axis=1).values.ravel()    </p>\n<ol>\n<li>NN<br>\nI used the simplest feed-forward neural network.<br>\nsame features as LightGBM, for pre-processing, I used ”RankGauss“ recommended by <a href=\"https://www.kaggle.com/Michael\" target=\"_blank\">@Michael</a> Jahrer(<a href=\"https://www.kaggle.com/c/porto-seguro-safe-driver-prediction/discussion/44629)\" target=\"_blank\">https://www.kaggle.com/c/porto-seguro-safe-driver-prediction/discussion/44629)</a>, for training I used BatchNorman, big dropout and nothing else.</li>\n</ol>\n<p>small tricks.<br>\nI separate Perishable and Non-Perishable variable to train different models. and this give me a little improvement.</p>\n<h1>Validation Framework</h1>\n<p>I used the same framework recommended by <a href=\"https://www.kaggle.com/Ceshine\" target=\"_blank\">@Ceshine</a> lee, but I paid careful attention to first 5 days and last 11 days, I only add variables that both have improvement to first 5 days, last 11 days and Public Board, this give me a rather steady improvement on both public and private. </p>",
  "comments": [
    {
      "id": 269179,
      "author_name": "CPMP",
      "author_url": "",
      "post_date": "2018-01-16T11:54:34.843000",
      "content": "<p>Nice!</p>",
      "votes": 1,
      "replies": [
        {
          "id": 269213,
          "author_name": "🐳鲲(China)",
          "author_url": "",
          "post_date": "2018-01-16T13:31:32.033000",
          "content": "<p>thanks @CPMP, I was trying to use one year data before the same as your script in WTF but get bad result - -, but your script gives me some ideas! thanks for sharing!!</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 269215,
          "author_name": "CPMP",
          "author_url": "",
          "post_date": "2018-01-16T13:33:20.903000",
          "content": "<p>Yes, training one previous year data as I did in WTF does not work here.  I lost a week trying to make it work :(</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 269227,
          "author_name": "🐳鲲(China)",
          "author_url": "",
          "post_date": "2018-01-16T13:51:59.423000",
          "content": "<p>I lost one day, lol~ I was trying to make my feedforward NN performance as good as yours, but failed, only 0.521 in private, but I should do better in the next time :） </p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 269230,
          "author_name": "CPMP",
          "author_url": "",
          "post_date": "2018-01-16T13:56:10.347000",
          "content": "<p>Let's team next time!</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 269237,
          "author_name": "🐳鲲(China)",
          "author_url": "",
          "post_date": "2018-01-16T14:09:12.040000",
          "content": "<p>My door is always opening!  thanks for your invitation, sir🙈!</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 269011,
      "author_name": "Gerryl",
      "author_url": "",
      "post_date": "2018-01-16T03:51:34.013000",
      "content": "<p>Thanks for sharing!</p>",
      "votes": 1,
      "replies": [
        {
          "id": 269071,
          "author_name": "🐳鲲(China)",
          "author_url": "",
          "post_date": "2018-01-16T06:15:29.120000",
          "content": "<p>🙂</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 275225,
      "author_name": "shark",
      "author_url": "",
      "post_date": "2018-01-28T14:19:01.523000",
      "content": "<p>hello 鲲(China).How does zero crossing rate features perform?Does them rank top 10% in feature importance?</p>",
      "votes": 0,
      "replies": [
        {
          "id": 275369,
          "author_name": "🐳鲲(China)",
          "author_url": "",
          "post_date": "2018-01-29T00:41:57.033000",
          "content": "<p>Sure, but the function that i written is not optimized. ɿ😏ɾ</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 277054,
          "author_name": "shark",
          "author_url": "",
          "post_date": "2018-02-02T03:45:31.303000",
          "content": "<p>I'm wonder how do you optimized this function.It seems amazing.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 277091,
          "author_name": "🐳鲲(China)",
          "author_url": "",
          "post_date": "2018-02-02T05:26:55.843000",
          "content": "<p>I didn't optimized it - -!</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 269626,
      "author_name": "feng",
      "author_url": "",
      "post_date": "2018-01-17T03:18:56.293000",
      "content": "<p>Thanks for sharing!\nThere some question for me, could you share some insights?</p>\n\n<p>If there is improvement to first 5 days, last 11 days, then the improvement to the full 16 days? or why you didn't use the full 16 days to calculate the score?</p>\n\n<p>I use the same validation framework, but I only use the full 16 days to evaluate,  but the improve of local validation score result in the decrease of public board score.                                                                                                                                             </p>",
      "votes": 0,
      "replies": [
        {
          "id": 271040,
          "author_name": "🐳鲲(China)",
          "author_url": "",
          "post_date": "2018-01-19T15:06:46.570000",
          "content": "<p>Improvement to the full 16 days is not equal to improvement to both first 5 and last 11 days, the leadboard is cut by time. Sometimes, improvement to first 5 day, but decrease to last 11 days. The private board is about the last 11 days, so we should choose features that do both good to first 5 and last 11.</p>",
          "votes": 3,
          "replies": []
        }
      ]
    }
  ],
  "comment_count": 14,
  "messages": [
    {
      "id": 268981,
      "postDate": "2018-01-16T02:44:34.283Z",
      "content": "<p><img src=\"http://imglf5.nosdn.127.net/img/OEUzbU5jenB4YlRsQWNNcnk3Um5DVnFkc0Y0eEQyMFQzRXRlRXRBWW5NakMyU28yQnc4MS9nPT0.jpeg?imageView&amp;thumbnail=2086y226&amp;type=jpg&amp;quality=96&amp;stripmeta=0&amp;type=jpg\" alt=\"dd\"></p>\n<h1>Models</h1>\n<p>I use two models to solve this problem</p>\n<ol>\n<li><p>LightGBM, it's based on Ceshine lee's script, but I add some other new features.<br>\na) zero crossing rate (<a href=\"https://en.wikipedia.org/wiki/Zero-crossing_rate)\" target=\"_blank\">https://en.wikipedia.org/wiki/Zero-crossing_rate)</a>, I create this feature for different windows(1, 3, 7, 14, 30, 60) and levels(item level, store*family level)<br>\nbelow is my implementation  </p>\n<p>def corss_zero(row):<br>\n      return (((row[:-1] * row[1:]) == 0) * ~(row[:-1] == row[1:])).sum()</p></li>\n</ol>\n<p>b) zero-sales counts in different windows  </p>\n<pre><code>:  == 0)  \n    :  == 0)  \n    :  == 0) \n</code></pre>\n<p>b) lastest promo day in last 30 days  </p>\n<pre><code> fo_in_row(row):  \n =   \n i in row:  \n     +=   \n     i == :  \n         j  \n -  \n</code></pre>\n<p>\"lastest_promo_30\": get_timespan(promo_2017, t2017, 30, 30).apply(lambda row: fo_in_row(row[::-1]), axis=1).values.ravel()    </p>\n<ol>\n<li>NN<br>\nI used the simplest feed-forward neural network.<br>\nsame features as LightGBM, for pre-processing, I used ”RankGauss“ recommended by <a href=\"https://www.kaggle.com/Michael\" target=\"_blank\">@Michael</a> Jahrer(<a href=\"https://www.kaggle.com/c/porto-seguro-safe-driver-prediction/discussion/44629)\" target=\"_blank\">https://www.kaggle.com/c/porto-seguro-safe-driver-prediction/discussion/44629)</a>, for training I used BatchNorman, big dropout and nothing else.</li>\n</ol>\n<p>small tricks.<br>\nI separate Perishable and Non-Perishable variable to train different models. and this give me a little improvement.</p>\n<h1>Validation Framework</h1>\n<p>I used the same framework recommended by <a href=\"https://www.kaggle.com/Ceshine\" target=\"_blank\">@Ceshine</a> lee, but I paid careful attention to first 5 days and last 11 days, I only add variables that both have improvement to first 5 days, last 11 days and Public Board, this give me a rather steady improvement on both public and private. </p>",
      "rawMarkdown": "![dd][1]\n\n# Models\nI use two models to solve this problem\n\n1. LightGBM, it's based on Ceshine lee's script, but I add some other new features.\na) zero crossing rate (https://en.wikipedia.org/wiki/Zero-crossing_rate), I create this feature for different windows(1, 3, 7, 14, 30, 60) and levels(item level, store*family level)\nbelow is my implementation  \n\n    def corss_zero(row):\n          return (((row[:-1] * row[1:]) == 0) * ~(row[:-1] == row[1:])).sum()\n\nb) zero-sales counts in different windows  \n\n    \"zeros_28_2017\": (get_timespan(df_2017, t2017, 28, 28) == 0).sum(axis=1).values  \n        \"zeros_56_2017\": (get_timespan(df_2017, t2017, 56, 56) == 0).sum(axis=1).values  \n        \"zeros_84_2017\": (get_timespan(df_2017, t2017, 84, 84) == 0).sum(axis=1).values \n\nb) lastest promo day in last 30 days  \n\n    def fo_in_row(row):  \n    j = 0  \n    for i in row:  \n        j += 1  \n        if i == 1:  \n            return j  \n    return -1  \n\"lastest_promo_30\": get_timespan(promo_2017, t2017, 30, 30).apply(lambda row: fo_in_row(row[::-1]), axis=1).values.ravel()    \n2. NN\nI used the simplest feed-forward neural network.\nsame features as LightGBM, for pre-processing, I used ”RankGauss“ recommended by @Michael Jahrer(https://www.kaggle.com/c/porto-seguro-safe-driver-prediction/discussion/44629), for training I used BatchNorman, big dropout and nothing else.\n\nsmall tricks.\nI separate Perishable and Non-Perishable variable to train different models. and this give me a little improvement.\n\n# Validation Framework\nI used the same framework recommended by @Ceshine lee, but I paid careful attention to first 5 days and last 11 days, I only add variables that both have improvement to first 5 days, last 11 days and Public Board, this give me a rather steady improvement on both public and private. \n\n\n  [1]: http://imglf5.nosdn.127.net/img/OEUzbU5jenB4YlRsQWNNcnk3Um5DVnFkc0Y0eEQyMFQzRXRlRXRBWW5NakMyU28yQnc4MS9nPT0.jpeg?imageView&amp;thumbnail=2086y226&amp;type=jpg&amp;quality=96&amp;stripmeta=0&amp;type=jpg",
      "votes": 18
    },
    {
      "id": 269179,
      "postDate": "2018-01-16T11:54:34.843Z",
      "content": "<p>Nice!</p>",
      "rawMarkdown": "Nice!",
      "votes": 1,
      "replies": [
        {
          "id": 269213,
          "postDate": "2018-01-16T13:31:32.033Z",
          "content": "<p>thanks @CPMP, I was trying to use one year data before the same as your script in WTF but get bad result - -, but your script gives me some ideas! thanks for sharing!!</p>",
          "rawMarkdown": "thanks @CPMP, I was trying to use one year data before the same as your script in WTF but get bad result - -, but your script gives me some ideas! thanks for sharing!!"
        },
        {
          "id": 269215,
          "postDate": "2018-01-16T13:33:20.903Z",
          "content": "<p>Yes, training one previous year data as I did in WTF does not work here.  I lost a week trying to make it work :(</p>",
          "rawMarkdown": "Yes, training one previous year data as I did in WTF does not work here.  I lost a week trying to make it work :(",
          "votes": 1
        },
        {
          "id": 269227,
          "postDate": "2018-01-16T13:51:59.423Z",
          "content": "<p>I lost one day, lol~ I was trying to make my feedforward NN performance as good as yours, but failed, only 0.521 in private, but I should do better in the next time :） </p>",
          "rawMarkdown": "I lost one day, lol~ I was trying to make my feedforward NN performance as good as yours, but failed, only 0.521 in private, but I should do better in the next time :） ",
          "votes": 1
        },
        {
          "id": 269230,
          "postDate": "2018-01-16T13:56:10.347Z",
          "content": "<p>Let's team next time!</p>",
          "rawMarkdown": "Let's team next time!",
          "votes": 1
        },
        {
          "id": 269237,
          "postDate": "2018-01-16T14:09:12.040Z",
          "content": "<p>My door is always opening!  thanks for your invitation, sir🙈!</p>",
          "rawMarkdown": "My door is always opening!  thanks for your invitation, sir🙈!",
          "votes": 1
        }
      ]
    },
    {
      "id": 269011,
      "postDate": "2018-01-16T03:51:34.013Z",
      "content": "<p>Thanks for sharing!</p>",
      "rawMarkdown": "Thanks for sharing!",
      "votes": 1,
      "replies": [
        {
          "id": 269071,
          "postDate": "2018-01-16T06:15:29.120Z",
          "content": "<p>🙂</p>",
          "rawMarkdown": "🙂"
        }
      ]
    },
    {
      "id": 275225,
      "postDate": "2018-01-28T14:19:01.523Z",
      "content": "<p>hello 鲲(China).How does zero crossing rate features perform?Does them rank top 10% in feature importance?</p>",
      "rawMarkdown": "hello 鲲(China).How does zero crossing rate features perform?Does them rank top 10% in feature importance?\n",
      "replies": [
        {
          "id": 275369,
          "postDate": "2018-01-29T00:41:57.033Z",
          "content": "<p>Sure, but the function that i written is not optimized. ɿ😏ɾ</p>",
          "rawMarkdown": "Sure, but the function that i written is not optimized. ɿ😏ɾ"
        },
        {
          "id": 277054,
          "postDate": "2018-02-02T03:45:31.303Z",
          "content": "<p>I'm wonder how do you optimized this function.It seems amazing.</p>",
          "rawMarkdown": "I'm wonder how do you optimized this function.It seems amazing."
        },
        {
          "id": 277091,
          "postDate": "2018-02-02T05:26:55.843Z",
          "content": "<p>I didn't optimized it - -!</p>",
          "rawMarkdown": "I didn't optimized it - -!"
        }
      ]
    },
    {
      "id": 269626,
      "postDate": "2018-01-17T03:18:56.293Z",
      "content": "<p>Thanks for sharing!\nThere some question for me, could you share some insights?</p>\n\n<p>If there is improvement to first 5 days, last 11 days, then the improvement to the full 16 days? or why you didn't use the full 16 days to calculate the score?</p>\n\n<p>I use the same validation framework, but I only use the full 16 days to evaluate,  but the improve of local validation score result in the decrease of public board score.                                                                                                                                             </p>",
      "rawMarkdown": "Thanks for sharing!\nThere some question for me, could you share some insights?\n\nIf there is improvement to first 5 days, last 11 days, then the improvement to the full 16 days? or why you didn't use the full 16 days to calculate the score?\n\nI use the same validation framework, but I only use the full 16 days to evaluate,  but the improve of local validation score result in the decrease of public board score.                                                                                                                                             \n",
      "replies": [
        {
          "id": 271040,
          "postDate": "2018-01-19T15:06:46.570Z",
          "content": "<p>Improvement to the full 16 days is not equal to improvement to both first 5 and last 11 days, the leadboard is cut by time. Sometimes, improvement to first 5 day, but decrease to last 11 days. The private board is about the last 11 days, so we should choose features that do both good to first 5 and last 11.</p>",
          "rawMarkdown": "Improvement to the full 16 days is not equal to improvement to both first 5 and last 11 days, the leadboard is cut by time. Sometimes, improvement to first 5 day, but decrease to last 11 days. The private board is about the last 11 days, so we should choose features that do both good to first 5 and last 11.",
          "votes": 3
        }
      ]
    }
  ],
  "complete": true,
  "source": "live",
  "fetched_at": "2026-10-19T08:37:05Z",
  "competition_id": 7391,
  "competition_slug": "favorita-grocery-sales-forecasting",
  "team_id": 1014225,
  "solution_url": ""
}