{
  "id": 2861,
  "title": "Solution to this competition",
  "url": "/competitions/acm-sf-chapter-hackathon-big/writeups/rapstar-solution-to-this-competition",
  "author_name": "",
  "post_date": "2012-10-12T06:47:01.743Z",
  "votes": 11,
  "comment_count": 4,
  "views": 8425,
  "content": "<p><span>Congrats to everyone in this competition. I notice that the rule&nbsp;<span>states that:</span></span></p>\r\n<h3>WINNING SOLUTIONS MUST BE POSTED TO THE FORUMS</h3>\r\n<p>And some teams have present their solutions in small version of this competition in foruma. I here present our solution to the big version of this competition in this topic.</p>\r\n<p>We use naive bayes as our algorithm in this competition. The features we used is:</p>\r\n<ol>\r\n<li>query </li><li>time </li><li>user </li></ol>\r\n<p><strong>A.</strong> We want to know the probability 𝑝(𝑖│𝑐) that user click sku 𝑖 in context 𝑐. We use naive bayes to predict this probability. Then&nbsp;select 5 item with highest predicted probability as prediction in context 𝑐. Here&nbsp;context 𝑐 is query&nbsp;&nbsp;𝑞.</p>\r\n<p>The first context we used is query. By naive bayes, we have:</p>\r\n<div style=\"padding-left:30px\">𝑝(𝑖│𝑐)∝𝑝(𝑖)×∏𝑝(𝑤_𝑘 |𝑖)&nbsp;</div>\r\n<div>here&nbsp;𝑝(𝑖) is prior and we use the frequency that item&nbsp;𝑖 appears in its category as prior.</div>\r\n<div>∏𝑝(𝑤_𝑘 |𝑖)&nbsp;is the likelihood and&nbsp;𝑝(𝑤_𝑘 |𝑖) is the probability that word&nbsp;𝑤_𝑘 apprears when we see item&nbsp;𝑖.</div>\r\n<div><strong>B.</strong> We use time information in our model. We d<span>ivided data into 12-day time periods based on click_time. Then used a smoothed frequency of items&nbsp;𝑖 appears in its category in its time period as prior in A.</span></div>\r\n<div><span><strong>C.</strong> We also use a bigram model to improve naive bayes. The ∏𝑝(𝑤_𝑘 |𝑖)&nbsp;&nbsp;likelihood in A use words conditional probability. We generate a bigram model and use naive bayes model to fit it too. We generate bigram data for each query&nbsp;𝑞\r\n as follows:</span></div>\r\n<div>\r\n<ol>\r\n<li>suppose use query “xbox call of duty” </li><li>rerank to “call duty xbox&quot; by&nbsp;alphabetic order ( with elimination of &quot;of&quot; as stopwords)\r\n</li><li>bigram: [”call duty”, ”call xbox&quot;, “duty xbox“] </li><li>use naive bayes to fit it as the same as above. </li></ol>\r\n</div>\r\n<div>Then we use a linear combination to ensemble the unigram prediction and bigram prediction.</div>\r\n<div><strong>D.</strong>&nbsp;We did some data processing. The first is query cleanning. In big version of this competition, we did 1,lemmatization;2,split words and numbers such as &quot;xbox360&quot; to &quot;xbox 360&quot;. we also did some words correction in small version of this\r\n competition.</div>\r\n<div><strong>E. </strong>We rank the items that user have clicked by query&nbsp;&nbsp;𝑞 lower. Suppose we have prediction a,b,c,d,e when he query &nbsp;𝑞 and&nbsp;user &nbsp;<em>i\r\n</em>clicked items a,c. We rerank prediction b,d,e,a,c for user <em>i</em>.</div>\r\n<div><strong>F.</strong> We use python to implement all algorithms. The only 3rd lib need to install is nltk. We use it for&nbsp;lemmatization in data processing. The rest use puer python. The version of python is 2.7, as there is one function not supported in 2.6-\r\n version. &nbsp;For more information, Check readme.txt in the soucecode.&nbsp;Please download the second attached file. Because I find nothing can delete the first attached file in the system.<br>\r\n&nbsp;</div>",
  "messages": [
    {
      "id": "15468",
      "postDate": "10/12/2012 05:50:42",
      "content": "<p><span>Congrats to everyone in this competition. I notice that the rule&nbsp;<span>states that:</span></span></p>\r\n<h3>WINNING SOLUTIONS MUST BE POSTED TO THE FORUMS</h3>\r\n<p>And some teams have present their solutions in small version of this competition in foruma. I here present our solution to the big version of this competition in this topic.</p>\r\n<p>We use naive bayes as our algorithm in this competition. The features we used is:</p>\r\n<ol>\r\n<li>query </li><li>time </li><li>user </li></ol>\r\n<p><strong>A.</strong> We want to know the probability 𝑝(𝑖│𝑐) that user click sku 𝑖 in context 𝑐. We use naive bayes to predict this probability. Then&nbsp;select 5 item with highest predicted probability as prediction in context 𝑐. Here&nbsp;context 𝑐 is query&nbsp;&nbsp;𝑞.</p>\r\n<p>The first context we used is query. By naive bayes, we have:</p>\r\n<div style=\"padding-left:30px\">𝑝(𝑖│𝑐)∝𝑝(𝑖)×∏𝑝(𝑤_𝑘 |𝑖)&nbsp;</div>\r\n<div>here&nbsp;𝑝(𝑖) is prior and we use the frequency that item&nbsp;𝑖 appears in its category as prior.</div>\r\n<div>∏𝑝(𝑤_𝑘 |𝑖)&nbsp;is the likelihood and&nbsp;𝑝(𝑤_𝑘 |𝑖) is the probability that word&nbsp;𝑤_𝑘 apprears when we see item&nbsp;𝑖.</div>\r\n<div><strong>B.</strong> We use time information in our model. We d<span>ivided data into 12-day time periods based on click_time. Then used a smoothed frequency of items&nbsp;𝑖 appears in its category in its time period as prior in A.</span></div>\r\n<div><span><strong>C.</strong> We also use a bigram model to improve naive bayes. The ∏𝑝(𝑤_𝑘 |𝑖)&nbsp;&nbsp;likelihood in A use words conditional probability. We generate a bigram model and use naive bayes model to fit it too. We generate bigram data for each query&nbsp;𝑞\r\n as follows:</span></div>\r\n<div>\r\n<ol>\r\n<li>suppose use query “xbox call of duty” </li><li>rerank to “call duty xbox&quot; by&nbsp;alphabetic order ( with elimination of &quot;of&quot; as stopwords)\r\n</li><li>bigram: [”call duty”, ”call xbox&quot;, “duty xbox“] </li><li>use naive bayes to fit it as the same as above. </li></ol>\r\n</div>\r\n<div>Then we use a linear combination to ensemble the unigram prediction and bigram prediction.</div>\r\n<div><strong>D.</strong>&nbsp;We did some data processing. The first is query cleanning. In big version of this competition, we did 1,lemmatization;2,split words and numbers such as &quot;xbox360&quot; to &quot;xbox 360&quot;. we also did some words correction in small version of this\r\n competition.</div>\r\n<div><strong>E. </strong>We rank the items that user have clicked by query&nbsp;&nbsp;𝑞 lower. Suppose we have prediction a,b,c,d,e when he query &nbsp;𝑞 and&nbsp;user &nbsp;<em>i\r\n</em>clicked items a,c. We rerank prediction b,d,e,a,c for user <em>i</em>.</div>\r\n<div><strong>F.</strong> We use python to implement all algorithms. The only 3rd lib need to install is nltk. We use it for&nbsp;lemmatization in data processing. The rest use puer python. The version of python is 2.7, as there is one function not supported in 2.6-\r\n version. &nbsp;For more information, Check readme.txt in the soucecode.&nbsp;Please download the second attached file. Because I find nothing can delete the first attached file in the system.<br>\r\n&nbsp;</div>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "15490",
      "postDate": "10/12/2012 21:35:48",
      "content": "<p>Major techniques used in my solution are summarized as following:<br>\r\n<br>\r\n1. Query/keyword normalization, such as case lowering, non-alphanumeric-character removal, stopword removal, and word ordering.<br>\r\n<br>\r\n2. Obtain a rule of user information: 98~99% people don't click items multiple times.<br>\r\n<br>\r\n3. For head queries that have sufficient samples, the feature tuple is (query, category, week number of query time) for ML. The reason of using week number is that besbuy usually changes promotions and categories weekly<br>\r\n<br>\r\n4. For tail queries that have few or no samples, kNN is used to find matched queries in a query set in which every query at least results in clicking the given category. The distance is defined &nbsp;by common keyword # / max (keyword #). I believe using TF-IDF\r\n weighted distance could improve performance further. I don't optimize the algorithm of kNN since it takes less than one hour and data will be cached.<br>\r\n<br>\r\nThe code is written in Python. Redis is used for DB.<br>\r\n<br>\r\nRAM requirement: the code makes a Redis DB of 400MB. A linux PC with 2G RAM should be able to run the code. BTW,&nbsp;I don't index users and queries. If do so, the DB size could be reduced by half.&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "22656",
      "postDate": "04/11/2013 21:31:43",
      "content": "<p><strong>Hello,</strong></p>\r\n<p>&nbsp;</p>\r\n<p>It seems that you have only used train.csv for your algorithms.Is Given Product data is of no use . Or that can be used to improve the performance.</p>\r\n<p>&nbsp;</p>\r\n<p>Please Reply<strong> ASAP<br>\r\n</strong></p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "31020",
      "postDate": "09/17/2013 00:34:39",
      "content": "<p>Would it be possible to get the SKUs for the test set? It would be nice to be able to compare apples-to-apples when testing new algorithms and seeing how they perform against the solutions presented here.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "161680",
      "postDate": "02/15/2017 07:05:38",
      "content": "<p>Is there any way I can submit my predictions now, to compare my results?</p>",
      "rawMarkdown": "Is there any way I can submit my predictions now, to compare my results?",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 15490,
      "author_name": "songgc",
      "author_url": "",
      "post_date": "10/12/2012 21:35:48",
      "content": "<p>Major techniques used in my solution are summarized as following:<br>\r\n<br>\r\n1. Query/keyword normalization, such as case lowering, non-alphanumeric-character removal, stopword removal, and word ordering.<br>\r\n<br>\r\n2. Obtain a rule of user information: 98~99% people don't click items multiple times.<br>\r\n<br>\r\n3. For head queries that have sufficient samples, the feature tuple is (query, category, week number of query time) for ML. The reason of using week number is that besbuy usually changes promotions and categories weekly<br>\r\n<br>\r\n4. For tail queries that have few or no samples, kNN is used to find matched queries in a query set in which every query at least results in clicking the given category. The distance is defined &nbsp;by common keyword # / max (keyword #). I believe using TF-IDF\r\n weighted distance could improve performance further. I don't optimize the algorithm of kNN since it takes less than one hour and data will be cached.<br>\r\n<br>\r\nThe code is written in Python. Redis is used for DB.<br>\r\n<br>\r\nRAM requirement: the code makes a Redis DB of 400MB. A linux PC with 2G RAM should be able to run the code. BTW,&nbsp;I don't index users and queries. If do so, the DB size could be reduced by half.&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 22656,
      "author_name": "karanchugh",
      "author_url": "",
      "post_date": "04/11/2013 21:31:43",
      "content": "<p><strong>Hello,</strong></p>\r\n<p>&nbsp;</p>\r\n<p>It seems that you have only used train.csv for your algorithms.Is Given Product data is of no use . Or that can be used to improve the performance.</p>\r\n<p>&nbsp;</p>\r\n<p>Please Reply<strong> ASAP<br>\r\n</strong></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 31020,
      "author_name": "davidarthur",
      "author_url": "",
      "post_date": "09/17/2013 00:34:39",
      "content": "<p>Would it be possible to get the SKUs for the test set? It would be nice to be able to compare apples-to-apples when testing new algorithms and seeing how they perform against the solutions presented here.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 161680,
      "author_name": "shantokhoka",
      "author_url": "",
      "post_date": "02/15/2017 07:05:38",
      "content": "<p>Is there any way I can submit my predictions now, to compare my results?</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "15468": "",
    "15490": "",
    "22656": "",
    "31020": "",
    "161680": "Is there any way I can submit my predictions now, to compare my results?"
  },
  "source": "existing_discussion",
  "complete": true,
  "competition_id": 3064,
  "competition_slug": "acm-sf-chapter-hackathon-big",
  "team_id": 22346,
  "solution_url": "/competitions/acm-sf-chapter-hackathon-big/writeups/rapstar-solution-to-this-competition"
}