{
  "id": 82614,
  "title": "Winning solution (link to kernel inside)",
  "url": "/competitions/ga-customer-revenue-prediction/discussion/82614",
  "author_name": "Konstantin Nikolaev",
  "post_date": "2019-03-02T20:59:24.303000",
  "votes": 64,
  "comment_count": 4,
  "views": 0,
  "content": "<p>Hi Kagglers,</p>\n\n<p>Key points of my solution:</p>\n\n<p><strong>Train creation</strong>\nAs we have 168 days (2018/05/01-2018/10/15) of sessions  for customers in the test, 62 days (2018/12/01-2019/01/31) of target calculation period and 46 days (16/10/2018-30/11/2018) of gap between above two windows, it’s absolutely clear to construct train data by analogy. \nI took 4 non-overlapping windows of 168 days, calculated features for users in each period and calculated target for each user on each corresponding 62-day window. Then those 4 dataframes were combined in one train set.</p>\n\n<p><strong>Feature engineering</strong>\nVery simple: \n- label-encoded categorical features, \n- some time features in 168-day window such as intervals between user’s first session and window’s start and from user’s last session to window’s end,\n- some statistical features based on user’s pageviews and hits.\nFeatures were calculated only on 168-day window data without using sessions from next 46-day window, because I didn’t use “external” data from demo account for 16/10/2018-30/11/2018 period.</p>\n\n<p><strong>Problem as “classification and regression”</strong>\nFirstly, I predicted probability of returning of customer using all train set. Secondly, I predicted the amount of transactions for those customers who returned. So, in regression task train was filtered only by customers who had a session in  62-day window. As final prediction I multiplied probability of returning by predicted amount for returned customer.\nApproach of direct prediction by only regression using all train set  gives only 0.88320 score (it’ll be the 6th place on LB). So the trick of adding classification component was crucial. </p>\n\n<p>You can find the code <a href=\"https://www.kaggle.com/kostoglot/test-score#L144\">here</a>.\nNote: Score is slightly different from the score on LB (0.88143 instead of 0.88140) due to different environment on my local machine.</p>",
  "messages": [
    {
      "id": 482360,
      "postDate": "2019-03-02T20:59:24.303Z",
      "content": "<p>Hi Kagglers,</p>\n\n<p>Key points of my solution:</p>\n\n<p><strong>Train creation</strong>\nAs we have 168 days (2018/05/01-2018/10/15) of sessions  for customers in the test, 62 days (2018/12/01-2019/01/31) of target calculation period and 46 days (16/10/2018-30/11/2018) of gap between above two windows, it’s absolutely clear to construct train data by analogy. \nI took 4 non-overlapping windows of 168 days, calculated features for users in each period and calculated target for each user on each corresponding 62-day window. Then those 4 dataframes were combined in one train set.</p>\n\n<p><strong>Feature engineering</strong>\nVery simple: \n- label-encoded categorical features, \n- some time features in 168-day window such as intervals between user’s first session and window’s start and from user’s last session to window’s end,\n- some statistical features based on user’s pageviews and hits.\nFeatures were calculated only on 168-day window data without using sessions from next 46-day window, because I didn’t use “external” data from demo account for 16/10/2018-30/11/2018 period.</p>\n\n<p><strong>Problem as “classification and regression”</strong>\nFirstly, I predicted probability of returning of customer using all train set. Secondly, I predicted the amount of transactions for those customers who returned. So, in regression task train was filtered only by customers who had a session in  62-day window. As final prediction I multiplied probability of returning by predicted amount for returned customer.\nApproach of direct prediction by only regression using all train set  gives only 0.88320 score (it’ll be the 6th place on LB). So the trick of adding classification component was crucial. </p>\n\n<p>You can find the code <a href=\"https://www.kaggle.com/kostoglot/test-score#L144\">here</a>.\nNote: Score is slightly different from the score on LB (0.88143 instead of 0.88140) due to different environment on my local machine.</p>",
      "rawMarkdown": "Hi Kagglers,\n\nKey points of my solution:\n\n**Train creation**\nAs we have 168 days (2018/05/01-2018/10/15) of sessions  for customers in the test, 62 days (2018/12/01-2019/01/31) of target calculation period and 46 days (16/10/2018-30/11/2018) of gap between above two windows, it’s absolutely clear to construct train data by analogy. \nI took 4 non-overlapping windows of 168 days, calculated features for users in each period and calculated target for each user on each corresponding 62-day window. Then those 4 dataframes were combined in one train set.\n\n**Feature engineering**\nVery simple: \n- label-encoded categorical features, \n- some time features in 168-day window such as intervals between user’s first session and window’s start and from user’s last session to window’s end,\n- some statistical features based on user’s pageviews and hits.\nFeatures were calculated only on 168-day window data without using sessions from next 46-day window, because I didn’t use “external” data from demo account for 16/10/2018-30/11/2018 period.\n\n**Problem as “classification and regression”**\nFirstly, I predicted probability of returning of customer using all train set. Secondly, I predicted the amount of transactions for those customers who returned. So, in regression task train was filtered only by customers who had a session in  62-day window. As final prediction I multiplied probability of returning by predicted amount for returned customer.\nApproach of direct prediction by only regression using all train set  gives only 0.88320 score (it’ll be the 6th place on LB). So the trick of adding classification component was crucial. \n\nYou can find the code [here](https://www.kaggle.com/kostoglot/test-score#L144).\nNote: Score is slightly different from the score on LB (0.88143 instead of 0.88140) due to different environment on my local machine.\n",
      "votes": 64
    },
    {
      "id": 482382,
      "postDate": "2019-03-02T22:05:39.283Z",
      "content": "<p>Congrats on getting the 1st place Konstantin! Thanks for sharing your solution, especially, for the Kernel! Your strategy is analog to hurdle models: <a href=\"https://seananderson.ca/2014/05/18/gamma-hurdle/\">https://seananderson.ca/2014/05/18/gamma-hurdle/</a></p>",
      "rawMarkdown": "Congrats on getting the 1st place Konstantin! Thanks for sharing your solution, especially, for the Kernel! Your strategy is analog to hurdle models: https://seananderson.ca/2014/05/18/gamma-hurdle/",
      "votes": 4
    },
    {
      "id": 482575,
      "postDate": "2019-03-03T09:08:05.030Z",
      "content": "<p>Congratulations Konstantin, and very interesting. Quite similar training approach here also oficial dataset only,  but didn't think of that clever sequencing of clasification and regression. Well deserved!</p>",
      "rawMarkdown": "Congratulations Konstantin, and very interesting. Quite similar training approach here also oficial dataset only,  but didn't think of that clever sequencing of clasification and regression. Well deserved!"
    },
    {
      "id": 723708,
      "postDate": "2020-01-20T10:58:44.467Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 1874360,
      "postDate": "2022-07-28T08:34:16.933Z",
      "content": "<p>Thanks for the solution.</p>",
      "rawMarkdown": "Thanks for the solution."
    }
  ],
  "comments": [
    {
      "id": 482382,
      "author_name": "Daniel Quelali",
      "author_url": "",
      "post_date": "2019-03-02T22:05:39.283000",
      "content": "<p>Congrats on getting the 1st place Konstantin! Thanks for sharing your solution, especially, for the Kernel! Your strategy is analog to hurdle models: <a href=\"https://seananderson.ca/2014/05/18/gamma-hurdle/\">https://seananderson.ca/2014/05/18/gamma-hurdle/</a></p>",
      "votes": 4,
      "replies": []
    },
    {
      "id": 482575,
      "author_name": "miguel perez",
      "author_url": "",
      "post_date": "2019-03-03T09:08:05.030000",
      "content": "<p>Congratulations Konstantin, and very interesting. Quite similar training approach here also oficial dataset only,  but didn't think of that clever sequencing of clasification and regression. Well deserved!</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 723708,
      "author_name": "",
      "author_url": "",
      "post_date": "2020-01-20T10:58:44.467000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1874360,
      "author_name": "Minh Võ Ngọc",
      "author_url": "",
      "post_date": "2022-07-28T08:34:16.933000",
      "content": "<p>Thanks for the solution.</p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "482360": "Hi Kagglers,\n\nKey points of my solution:\n\n**Train creation**\nAs we have 168 days (2018/05/01-2018/10/15) of sessions  for customers in the test, 62 days (2018/12/01-2019/01/31) of target calculation period and 46 days (16/10/2018-30/11/2018) of gap between above two windows, it’s absolutely clear to construct train data by analogy. \nI took 4 non-overlapping windows of 168 days, calculated features for users in each period and calculated target for each user on each corresponding 62-day window. Then those 4 dataframes were combined in one train set.\n\n**Feature engineering**\nVery simple: \n- label-encoded categorical features, \n- some time features in 168-day window such as intervals between user’s first session and window’s start and from user’s last session to window’s end,\n- some statistical features based on user’s pageviews and hits.\nFeatures were calculated only on 168-day window data without using sessions from next 46-day window, because I didn’t use “external” data from demo account for 16/10/2018-30/11/2018 period.\n\n**Problem as “classification and regression”**\nFirstly, I predicted probability of returning of customer using all train set. Secondly, I predicted the amount of transactions for those customers who returned. So, in regression task train was filtered only by customers who had a session in  62-day window. As final prediction I multiplied probability of returning by predicted amount for returned customer.\nApproach of direct prediction by only regression using all train set  gives only 0.88320 score (it’ll be the 6th place on LB). So the trick of adding classification component was crucial. \n\nYou can find the code [here](https://www.kaggle.com/kostoglot/test-score#L144).\nNote: Score is slightly different from the score on LB (0.88143 instead of 0.88140) due to different environment on my local machine.\n",
    "482382": "Congrats on getting the 1st place Konstantin! Thanks for sharing your solution, especially, for the Kernel! Your strategy is analog to hurdle models: https://seananderson.ca/2014/05/18/gamma-hurdle/",
    "482575": "Congratulations Konstantin, and very interesting. Quite similar training approach here also oficial dataset only,  but didn't think of that clever sequencing of clasification and regression. Well deserved!",
    "723708": "",
    "1874360": "Thanks for the solution."
  }
}