{
  "id": 10757,
  "title": "What's the size of data?",
  "url": "/competitions/avazu-ctr-prediction/discussion/10757",
  "author_name": "",
  "post_date": "2014-10-27T02:21:44.740Z",
  "votes": null,
  "comment_count": 26,
  "views": 7575,
  "content": "<p>Hello guys, I want to know the data size, but since the host is preparing the data, I don't see any information about the size.</p>\n<p>Does anyone know how much will be the data size?</p>\n\n<p>By the way, I am a TA of a Data Mining course, I am looking for interesting competition like this one for student's final project. Do you guys have any advices?</p>",
  "messages": [
    {
      "id": "56815",
      "postDate": "10/27/2014 02:21:44",
      "content": "<p>Hello guys, I want to know the data size, but since the host is preparing the data, I don't see any information about the size.</p>\n<p>Does anyone know how much will be the data size?</p>\n\n<p>By the way, I am a TA of a Data Mining course, I am looking for interesting competition like this one for student's final project. Do you guys have any advices?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "56816",
      "postDate": "10/27/2014 02:36:14",
      "content": "<p>[quote=Chun-Hao Chang;56815]</p>\n<p>Hello guys, I want to know the data size, but since the host is preparing the data, I don't see any information about the size.</p>\n<p>Does anyone know how much will be the data size?</p>\n<p>By the way, I am a TA of a Data Mining course, I am looking for interesting competition like this one for student's final project. Do you guys have any advices?</p>\n<p>[/quote]</p>\n\n<p>Hi Chun Hao,</p>\n\n<p>The training data set will be around 1.6GB, and test data set will about 170MB.</p>\n<p>The correct data set will be ready soon in one or two days.</p>\n\n<p>Thanks for your support and patience!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "56819",
      "postDate": "10/27/2014 03:32:10",
      "content": "<p>Thanks for the super quick response&#65281;</p>\n<p>It helps a lot.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "56824",
      "postDate": "10/27/2014 05:30:18",
      "content": "",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "56826",
      "postDate": "10/27/2014 05:54:35",
      "content": "<p>Dear all,</p>\n<p>I'm using open source R language for modelling purpose. R doesn't work with large data. I don't know what software to use in order to take part in this competition which has more than a GB of data. Could anyone please help me out by suggesting some ideas.</p>\n<p>Thank you</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "56828",
      "postDate": "10/27/2014 06:00:59",
      "content": "<p>Hey asho_sats:</p>\n<p>R loads every things&nbsp;into memory, and it is not a efficient language.&nbsp;</p>\n<p>You might need a general purposed language like Python, it's quite famous in Data Science community.&nbsp;</p>\n<p>As for data size issue, if the size is too big to store in memory. You can either store data in a Database or store in a file&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "56829",
      "postDate": "10/27/2014 06:06:51",
      "content": "<p>there are 48 millian records in the train data, about&nbsp;8.2G after decompression</p>\n<p>and 4.8&nbsp;millian in the test data, about 831M&nbsp;after decompression</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "56830",
      "postDate": "10/27/2014 06:13:08",
      "content": "<p>wow, that's huge, I am more excited right now :D!!!!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "56831",
      "postDate": "10/27/2014 06:17:54",
      "content": "<p>The data size is a bit of a problem for me too. I think there are a couple reasonable ways to proceed, but I guess we'll see what works best.&nbsp;</p>\n<p>One way is to use exclusively 'online learners' that can just take new data rows one at a time. In that case, you never have to load the entire thing into memory at once. This is a little limiting as far as what kinds of algorithms you can use, but this seems to be a pretty active area of development so you can find a bunch of research papers making online versions of stuff. The downside here is that this could mean a lot of custom implementation, which slows down one's ability to try a bunch of possibilities without committing too much time until they pan out.</p>\n<p>The other way, which seemed like a better bet to me, is to split the data up into smaller chunks and then ensemble the results. Since there's a good chunk of data, it means you can do a lot more with hold-out sets/etc than you could in a more data-starved case, so some techniques that'd otherwise be prone to over-fitting might be feasible here. If nothing else, this is probably a good first thing to do just to get a feeling for what class of algorithms are performing best with this data-set, before looking into writing up online versions of those things.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "56832",
      "postDate": "10/27/2014 06:24:28",
      "content": "<p>Hi, I have been looking into packages that allow R to efficiently manage large data such as ff or bigmemory. However&nbsp;if you just want to have a quick look at the data and start playing with them you may want to try (from a shell):</p>\n<p>shuf -n 100000 train.csv &gt; small.tmp</p>\n<p>head -n 1 train.csv &gt; h</p>\n<p>cat h small.tmp &gt; small.csv</p>\n<p>and you have a 100000 line subsample. I wonder whether the sampling is actually random, though.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57058",
      "postDate": "10/30/2014 18:19:18",
      "content": "<p>I am new to competitions with such large data set. I intend to use scikit-learn algos to begin with. As such I want to know whether I&nbsp;should&nbsp;proceed with this&nbsp;8GB data on a mac with 4GB ram and core i5? Or should I look for a more powerful mac?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57084",
      "postDate": "10/31/2014 02:10:22",
      "content": "<p>To Pronojit:</p>\n<p>I think not all the algorithms on Scikit-learn require you to load all data into memory at once.</p>\n<p>For example, you can try to load 10% of data and use that 10% to train your model. Repeat it ten times then you can get a fully trained model without crashing your memory.&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57096",
      "postDate": "10/31/2014 07:12:20",
      "content": "<p>To Chun-Hao Chang,</p>\n\n<p>&quot;I think not all the algorithms on Scikit-learn require you to load all data into memory at once.</p>\n<p>For example, you can try to load 10% of data and use that 10% to train your model. Repeat it ten times then you can get a fully trained model without crashing your memory.&quot;</p>\n<p>Can you please explain me if I want to do prediction for any test data row (any test sample) out of these 10 models&nbsp; which model&nbsp; I should choose? Or I should use all models and check which prediction (either 1 or o) is coming most number of time and use that?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57098",
      "postDate": "10/31/2014 07:32:06",
      "content": "<p>Dear Aniket:</p>\n<p>I think you misunderstood my point, you don't have to build multiple models just because you can not load data into memory at once.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57099",
      "postDate": "10/31/2014 08:49:37",
      "content": "<p>To Chun-Hao Chang,</p>\n<p>&nbsp;Thanks for reply, I again gone through your answer to Pronojit and as far as my understanding your are suggesting to iteratively update the model by&nbsp; taking 10% data in each pass.Can you please tell me by which classifier or by which package this can be done.Thanks in advance.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57100",
      "postDate": "10/31/2014 09:15:48",
      "content": "<p>Here is an example using Python Scikit-learn</p>\n<p>https://gist.github.com/GBJim/2c69fc444d1f0c740ace</p>\n<p>In this example you can see that I can train my GNB model multiple times and then predict the test data. Similarly, you can load part of your data into memory and repeat it until you get a fully trained model. &nbsp;</p>\n<p>But in this contest, don't use any classifier like the one I showed you. Because you need to compute a probability instead of giving a discrete tag.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57101",
      "postDate": "10/31/2014 09:30:36",
      "content": "<p>Thanks Again Chun-Hao Chang!!!!!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57111",
      "postDate": "10/31/2014 14:49:36",
      "content": "<p>You can get somehwere with R just using the built in utilities, but I agree it's not ideal. For example, this code fragment will create a series of tables of click against hour, which you can then merge yourself. It reads rows in 500k at a time (but that can be changed to suit your requirements)</p>\n\n<p><code>tl &lt;- list()<br>n &lt;- 1L<br>fin &lt;- file(&quot;train_rev2.csv&quot;,open=&quot;r&quot;)<br>trainHeader &lt;- readLines(fin,n=1L)<br>nchunk &lt;- 500000L<br>while(TRUE){<br> read.csv(fin,nrows=nchunk,header=FALSE,colClasses=&quot;character&quot;) -&gt; df.tmp<br> tl[[n]] &lt;- table(df.tmp[,c(&quot;V2&quot;,&quot;V3&quot;)])<br> n &lt;- n + 1L<br>}<br>close(fin)</code></p>\n<p><code>## tl now contains a list of tables with &quot;hour&quot; as the col names</code></p>\n<p>This should run fine as is with 512MB ram (probably less)</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57117",
      "postDate": "10/31/2014 16:20:02",
      "content": "<p>Chun-Hao Chang, maybe there&nbsp;is&nbsp;something I'm not understanding from your post. There are indeed plenty of models you can imagine updating or ensembling, but as far as I know,&nbsp;if you call fit multiple times on a single instance of an sklearn class, it will overwrite the previous values of the model. If you look at the code (it's in sklearn/naive_bayes.py for your example), it's pretty unambiguous. The steps are:</p>\n<ul>\n<li><span style=\"line-height: 1.4\">Set classes_ vector to the unique elements of y</span></li>\n<li>Zero out all the thetas, sigmas, and class priors</li>\n<li>Iterate over the classes</li>\n<ul>\n<li>Select all&nbsp;records in X belonging to the class,&nbsp;set&nbsp;the class coefficients based on the values selected from&nbsp;X.</li>\n</ul>\n</ul>\n<p>So, unless there are specific models which implement fit differently (I'm not aware of any), or you've patched sklearn, the code you've provided&nbsp;trains three models, throws out the first two, and then makes predictions based on the last model you trained.</p>\n<p>Have I missed something obvious?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57127",
      "postDate": "10/31/2014 18:49:25",
      "content": "<p>jdl37, I think you might be missing something in the code fragment... read.csv should include argument skip = n*500000, no?&nbsp; Otherwise it'll just keep reading the first 500k lines?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57128",
      "postDate": "10/31/2014 18:50:26",
      "content": "<p>kinnskogr: Thank you for you pointed it out! I am really grateful about you check through my idea.&nbsp;</p>\n<p>I have to say I didn't carefully check through the training methodology in scikit-learn and simply assumed GNB has incremental learning features.&nbsp;I am wrong, I hope you guys didn't go to the wrong direction because of my misleading post.</p>\n<p>Thankfully, Sklearn still has solutions in this kind of big data situation:</p>\n<p>Please check this document on Scikit-Learn</p>\n<p>http://scikit-learn.org/stable/modules/scaling_strategies.html</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57131",
      "postDate": "10/31/2014 20:22:29",
      "content": "<p>[quote=Chun-Hao Chang;56815]</p>\n<p>Hello guys, I want to know the data size, but since the host is preparing the data, I don't see any information about the size.</p>\n<p>Does anyone know how much will be the data size?</p>\n<p>By the way, I am a TA of a Data Mining course, I am looking for interesting competition like this one for student's final project. Do you guys have any advices?</p>\n<p>[/quote]</p>\n<p>There have been some issues in some earlier competitions with student groups competing (e.g., Partly Sunny with a chance of hashtags), so I'd be sure to remind your students of the competition rules, especially these:</p>\n<p><strong>One account per participant</strong></p>\n<p><strong>You cannot sign up to Kaggle from multiple accounts and therefore you cannot submit from multiple accounts.</strong></p>\n\n<p><strong>No private sharing outside teams</strong></p>\n<p><strong>Privately sharing code or data outside of teams is not permitted. It's okay to share code if made available to all participants on the forums.</strong></p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57136",
      "postDate": "10/31/2014 21:16:06",
      "content": "<p>It has 47686351 observations and 27 variables. Is that right?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57141",
      "postDate": "10/31/2014 22:47:52",
      "content": "<p>[quote=kinnskogr;57117]</p>\n<p>Chun-Hao Chang, maybe there&nbsp;is&nbsp;something I'm not understanding from your post. There are indeed plenty of models you can imagine updating or ensembling, but as far as I know,&nbsp;if you call fit multiple times on a single instance of an sklearn class, it will overwrite the previous values of the model. If you look at the code (it's in sklearn/naive_bayes.py for your example), it's pretty unambiguous. The steps are:</p>\n<ul>\n<li><span style=\"line-height: 1.4\">Set classes_ vector to the unique elements of y</span></li>\n<li>Zero out all the thetas, sigmas, and class priors</li>\n<li>Iterate over the classes</li>\n<ul>\n<li>Select all&nbsp;records in X belonging to the class,&nbsp;set&nbsp;the class coefficients based on the values selected from&nbsp;X.</li>\n</ul>\n</ul>\n<p>So, unless there are specific models which implement fit differently (I'm not aware of any), or you've patched sklearn, the code you've provided&nbsp;trains three models, throws out the first two, and then makes predictions based on the last model you trained.</p>\n<p>Have I missed something obvious?</p>\n<p>[/quote]</p>\n<p>Several sklearn classes have a partial fit method for mini-batch learning. The classes that I can recall are: SGDRegressor/Classifier, perceptron, all of the naive Bayes models and passive-aggressive models.</p>\n<p>I think you can call each with fit() the first time, and then partial_fit() subsequently, or you can call it with partial_fit() straight through, in which case you need to call it with the classes parameter, at least the first time. Here's some more info:&nbsp;<a href=\"http://scikit-learn.org/stable/modules/scaling_strategies.html#incremental-learning\">sklearn incremental training</a>.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57143",
      "postDate": "10/31/2014 23:37:58",
      "content": "<p>Hey David,</p>\n<p>&nbsp; &nbsp;That's right. My initial post wasn't quite complete without mentioning those. Chun-Hao has also pointed to the methods&nbsp;under the Incremental Learning section of http://scikit-learn.org/stable/modules/scaling_strategies.html. The point I was raising was that&nbsp;by convention, the fit() method will overwrite the model parameters. The partial_fit() method, again by convention, allows updating (and thankfully, the sklearn maintainers are great about enforcing conventions).</p>\n<p>Also, you don't need to call fit() the first time, there's a check in partial_fit() to&nbsp;handle&nbsp;newly initialized instances.</p>\n<p>Cheers,</p>\n<p>- Emanuel</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57234",
      "postDate": "11/03/2014 09:18:58",
      "content": "<p>@skwalas, not if the connection is opened in mode &quot;r&quot;. If it was opened in another mode, that would be true.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "57385",
      "postDate": "11/06/2014 05:52:06",
      "content": "<p>[quote=Nicholas Guttenberg;56831]</p>\n<p>The data size is a bit of a problem for me too. I think there are a couple reasonable ways to proceed, but I guess we'll see what works best.&nbsp;</p>\n<p>One way is to use exclusively 'online learners' that can just take new data rows one at a time. In that case, you never have to load the entire thing into memory at once. This is a little limiting as far as what kinds of algorithms you can use, but this seems to be a pretty active area of development so you can find a bunch of research papers making online versions of stuff. The downside here is that this could mean a lot of custom implementation, which slows down one's ability to try a bunch of possibilities without committing too much time until they pan out.</p>\n<p>The other way, which seemed like a better bet to me, is to split the data up into smaller chunks and then ensemble the results. Since there's a good chunk of data, it means you can do a lot more with hold-out sets/etc than you could in a more data-starved case, so some techniques that'd otherwise be prone to over-fitting might be feasible here. If nothing else, this is probably a good first thing to do just to get a feeling for what class of algorithms are performing best with this data-set, before looking into writing up online versions of those things.</p>\n<p>[/quote]</p>\n<p>Yet another way, is to buy* a giant server with 32 gigabytes memory.</p>\n\n<p>*Or rent one on AWS.</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 56816,
      "author_name": "stevewang0",
      "author_url": "",
      "post_date": "10/27/2014 02:36:14",
      "content": "<p>[quote=Chun-Hao Chang;56815]</p>\n<p>Hello guys, I want to know the data size, but since the host is preparing the data, I don't see any information about the size.</p>\n<p>Does anyone know how much will be the data size?</p>\n<p>By the way, I am a TA of a Data Mining course, I am looking for interesting competition like this one for student's final project. Do you guys have any advices?</p>\n<p>[/quote]</p>\n\n<p>Hi Chun Hao,</p>\n\n<p>The training data set will be around 1.6GB, and test data set will about 170MB.</p>\n<p>The correct data set will be ready soon in one or two days.</p>\n\n<p>Thanks for your support and patience!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 56819,
      "author_name": "ccha97u",
      "author_url": "",
      "post_date": "10/27/2014 03:32:10",
      "content": "<p>Thanks for the super quick response&#65281;</p>\n<p>It helps a lot.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 56824,
      "author_name": "asio555",
      "author_url": "",
      "post_date": "10/27/2014 05:30:18",
      "content": "",
      "votes": null,
      "replies": []
    },
    {
      "id": 56826,
      "author_name": "asio555",
      "author_url": "",
      "post_date": "10/27/2014 05:54:35",
      "content": "<p>Dear all,</p>\n<p>I'm using open source R language for modelling purpose. R doesn't work with large data. I don't know what software to use in order to take part in this competition which has more than a GB of data. Could anyone please help me out by suggesting some ideas.</p>\n<p>Thank you</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 56828,
      "author_name": "ccha97u",
      "author_url": "",
      "post_date": "10/27/2014 06:00:59",
      "content": "<p>Hey asho_sats:</p>\n<p>R loads every things&nbsp;into memory, and it is not a efficient language.&nbsp;</p>\n<p>You might need a general purposed language like Python, it's quite famous in Data Science community.&nbsp;</p>\n<p>As for data size issue, if the size is too big to store in memory. You can either store data in a Database or store in a file&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 56829,
      "author_name": "stevewang0",
      "author_url": "",
      "post_date": "10/27/2014 06:06:51",
      "content": "<p>there are 48 millian records in the train data, about&nbsp;8.2G after decompression</p>\n<p>and 4.8&nbsp;millian in the test data, about 831M&nbsp;after decompression</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 56830,
      "author_name": "ccha97u",
      "author_url": "",
      "post_date": "10/27/2014 06:13:08",
      "content": "<p>wow, that's huge, I am more excited right now :D!!!!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 56831,
      "author_name": "ngutten",
      "author_url": "",
      "post_date": "10/27/2014 06:17:54",
      "content": "<p>The data size is a bit of a problem for me too. I think there are a couple reasonable ways to proceed, but I guess we'll see what works best.&nbsp;</p>\n<p>One way is to use exclusively 'online learners' that can just take new data rows one at a time. In that case, you never have to load the entire thing into memory at once. This is a little limiting as far as what kinds of algorithms you can use, but this seems to be a pretty active area of development so you can find a bunch of research papers making online versions of stuff. The downside here is that this could mean a lot of custom implementation, which slows down one's ability to try a bunch of possibilities without committing too much time until they pan out.</p>\n<p>The other way, which seemed like a better bet to me, is to split the data up into smaller chunks and then ensemble the results. Since there's a good chunk of data, it means you can do a lot more with hold-out sets/etc than you could in a more data-starved case, so some techniques that'd otherwise be prone to over-fitting might be feasible here. If nothing else, this is probably a good first thing to do just to get a feeling for what class of algorithms are performing best with this data-set, before looking into writing up online versions of those things.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 56832,
      "author_name": "mariopasquato",
      "author_url": "",
      "post_date": "10/27/2014 06:24:28",
      "content": "<p>Hi, I have been looking into packages that allow R to efficiently manage large data such as ff or bigmemory. However&nbsp;if you just want to have a quick look at the data and start playing with them you may want to try (from a shell):</p>\n<p>shuf -n 100000 train.csv &gt; small.tmp</p>\n<p>head -n 1 train.csv &gt; h</p>\n<p>cat h small.tmp &gt; small.csv</p>\n<p>and you have a 100000 line subsample. I wonder whether the sampling is actually random, though.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57058,
      "author_name": "pronojit",
      "author_url": "",
      "post_date": "10/30/2014 18:19:18",
      "content": "<p>I am new to competitions with such large data set. I intend to use scikit-learn algos to begin with. As such I want to know whether I&nbsp;should&nbsp;proceed with this&nbsp;8GB data on a mac with 4GB ram and core i5? Or should I look for a more powerful mac?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57084,
      "author_name": "ccha97u",
      "author_url": "",
      "post_date": "10/31/2014 02:10:22",
      "content": "<p>To Pronojit:</p>\n<p>I think not all the algorithms on Scikit-learn require you to load all data into memory at once.</p>\n<p>For example, you can try to load 10% of data and use that 10% to train your model. Repeat it ten times then you can get a fully trained model without crashing your memory.&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57096,
      "author_name": "kapitsa2811",
      "author_url": "",
      "post_date": "10/31/2014 07:12:20",
      "content": "<p>To Chun-Hao Chang,</p>\n\n<p>&quot;I think not all the algorithms on Scikit-learn require you to load all data into memory at once.</p>\n<p>For example, you can try to load 10% of data and use that 10% to train your model. Repeat it ten times then you can get a fully trained model without crashing your memory.&quot;</p>\n<p>Can you please explain me if I want to do prediction for any test data row (any test sample) out of these 10 models&nbsp; which model&nbsp; I should choose? Or I should use all models and check which prediction (either 1 or o) is coming most number of time and use that?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57098,
      "author_name": "ccha97u",
      "author_url": "",
      "post_date": "10/31/2014 07:32:06",
      "content": "<p>Dear Aniket:</p>\n<p>I think you misunderstood my point, you don't have to build multiple models just because you can not load data into memory at once.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57099,
      "author_name": "kapitsa2811",
      "author_url": "",
      "post_date": "10/31/2014 08:49:37",
      "content": "<p>To Chun-Hao Chang,</p>\n<p>&nbsp;Thanks for reply, I again gone through your answer to Pronojit and as far as my understanding your are suggesting to iteratively update the model by&nbsp; taking 10% data in each pass.Can you please tell me by which classifier or by which package this can be done.Thanks in advance.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57100,
      "author_name": "ccha97u",
      "author_url": "",
      "post_date": "10/31/2014 09:15:48",
      "content": "<p>Here is an example using Python Scikit-learn</p>\n<p>https://gist.github.com/GBJim/2c69fc444d1f0c740ace</p>\n<p>In this example you can see that I can train my GNB model multiple times and then predict the test data. Similarly, you can load part of your data into memory and repeat it until you get a fully trained model. &nbsp;</p>\n<p>But in this contest, don't use any classifier like the one I showed you. Because you need to compute a probability instead of giving a discrete tag.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57101,
      "author_name": "kapitsa2811",
      "author_url": "",
      "post_date": "10/31/2014 09:30:36",
      "content": "<p>Thanks Again Chun-Hao Chang!!!!!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57111,
      "author_name": "jamesdlawrence",
      "author_url": "",
      "post_date": "10/31/2014 14:49:36",
      "content": "<p>You can get somehwere with R just using the built in utilities, but I agree it's not ideal. For example, this code fragment will create a series of tables of click against hour, which you can then merge yourself. It reads rows in 500k at a time (but that can be changed to suit your requirements)</p>\n\n<p><code>tl &lt;- list()<br>n &lt;- 1L<br>fin &lt;- file(&quot;train_rev2.csv&quot;,open=&quot;r&quot;)<br>trainHeader &lt;- readLines(fin,n=1L)<br>nchunk &lt;- 500000L<br>while(TRUE){<br> read.csv(fin,nrows=nchunk,header=FALSE,colClasses=&quot;character&quot;) -&gt; df.tmp<br> tl[[n]] &lt;- table(df.tmp[,c(&quot;V2&quot;,&quot;V3&quot;)])<br> n &lt;- n + 1L<br>}<br>close(fin)</code></p>\n<p><code>## tl now contains a list of tables with &quot;hour&quot; as the col names</code></p>\n<p>This should run fine as is with 512MB ram (probably less)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57117,
      "author_name": "kinnskogr",
      "author_url": "",
      "post_date": "10/31/2014 16:20:02",
      "content": "<p>Chun-Hao Chang, maybe there&nbsp;is&nbsp;something I'm not understanding from your post. There are indeed plenty of models you can imagine updating or ensembling, but as far as I know,&nbsp;if you call fit multiple times on a single instance of an sklearn class, it will overwrite the previous values of the model. If you look at the code (it's in sklearn/naive_bayes.py for your example), it's pretty unambiguous. The steps are:</p>\n<ul>\n<li><span style=\"line-height: 1.4\">Set classes_ vector to the unique elements of y</span></li>\n<li>Zero out all the thetas, sigmas, and class priors</li>\n<li>Iterate over the classes</li>\n<ul>\n<li>Select all&nbsp;records in X belonging to the class,&nbsp;set&nbsp;the class coefficients based on the values selected from&nbsp;X.</li>\n</ul>\n</ul>\n<p>So, unless there are specific models which implement fit differently (I'm not aware of any), or you've patched sklearn, the code you've provided&nbsp;trains three models, throws out the first two, and then makes predictions based on the last model you trained.</p>\n<p>Have I missed something obvious?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57127,
      "author_name": "taffeylewis",
      "author_url": "",
      "post_date": "10/31/2014 18:49:25",
      "content": "<p>jdl37, I think you might be missing something in the code fragment... read.csv should include argument skip = n*500000, no?&nbsp; Otherwise it'll just keep reading the first 500k lines?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57128,
      "author_name": "ccha97u",
      "author_url": "",
      "post_date": "10/31/2014 18:50:26",
      "content": "<p>kinnskogr: Thank you for you pointed it out! I am really grateful about you check through my idea.&nbsp;</p>\n<p>I have to say I didn't carefully check through the training methodology in scikit-learn and simply assumed GNB has incremental learning features.&nbsp;I am wrong, I hope you guys didn't go to the wrong direction because of my misleading post.</p>\n<p>Thankfully, Sklearn still has solutions in this kind of big data situation:</p>\n<p>Please check this document on Scikit-Learn</p>\n<p>http://scikit-learn.org/stable/modules/scaling_strategies.html</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57131,
      "author_name": "telser",
      "author_url": "",
      "post_date": "10/31/2014 20:22:29",
      "content": "<p>[quote=Chun-Hao Chang;56815]</p>\n<p>Hello guys, I want to know the data size, but since the host is preparing the data, I don't see any information about the size.</p>\n<p>Does anyone know how much will be the data size?</p>\n<p>By the way, I am a TA of a Data Mining course, I am looking for interesting competition like this one for student's final project. Do you guys have any advices?</p>\n<p>[/quote]</p>\n<p>There have been some issues in some earlier competitions with student groups competing (e.g., Partly Sunny with a chance of hashtags), so I'd be sure to remind your students of the competition rules, especially these:</p>\n<p><strong>One account per participant</strong></p>\n<p><strong>You cannot sign up to Kaggle from multiple accounts and therefore you cannot submit from multiple accounts.</strong></p>\n\n<p><strong>No private sharing outside teams</strong></p>\n<p><strong>Privately sharing code or data outside of teams is not permitted. It's okay to share code if made available to all participants on the forums.</strong></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57136,
      "author_name": "lucasqi",
      "author_url": "",
      "post_date": "10/31/2014 21:16:06",
      "content": "<p>It has 47686351 observations and 27 variables. Is that right?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57141,
      "author_name": "davidthaler",
      "author_url": "",
      "post_date": "10/31/2014 22:47:52",
      "content": "<p>[quote=kinnskogr;57117]</p>\n<p>Chun-Hao Chang, maybe there&nbsp;is&nbsp;something I'm not understanding from your post. There are indeed plenty of models you can imagine updating or ensembling, but as far as I know,&nbsp;if you call fit multiple times on a single instance of an sklearn class, it will overwrite the previous values of the model. If you look at the code (it's in sklearn/naive_bayes.py for your example), it's pretty unambiguous. The steps are:</p>\n<ul>\n<li><span style=\"line-height: 1.4\">Set classes_ vector to the unique elements of y</span></li>\n<li>Zero out all the thetas, sigmas, and class priors</li>\n<li>Iterate over the classes</li>\n<ul>\n<li>Select all&nbsp;records in X belonging to the class,&nbsp;set&nbsp;the class coefficients based on the values selected from&nbsp;X.</li>\n</ul>\n</ul>\n<p>So, unless there are specific models which implement fit differently (I'm not aware of any), or you've patched sklearn, the code you've provided&nbsp;trains three models, throws out the first two, and then makes predictions based on the last model you trained.</p>\n<p>Have I missed something obvious?</p>\n<p>[/quote]</p>\n<p>Several sklearn classes have a partial fit method for mini-batch learning. The classes that I can recall are: SGDRegressor/Classifier, perceptron, all of the naive Bayes models and passive-aggressive models.</p>\n<p>I think you can call each with fit() the first time, and then partial_fit() subsequently, or you can call it with partial_fit() straight through, in which case you need to call it with the classes parameter, at least the first time. Here's some more info:&nbsp;<a href=\"http://scikit-learn.org/stable/modules/scaling_strategies.html#incremental-learning\">sklearn incremental training</a>.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57143,
      "author_name": "kinnskogr",
      "author_url": "",
      "post_date": "10/31/2014 23:37:58",
      "content": "<p>Hey David,</p>\n<p>&nbsp; &nbsp;That's right. My initial post wasn't quite complete without mentioning those. Chun-Hao has also pointed to the methods&nbsp;under the Incremental Learning section of http://scikit-learn.org/stable/modules/scaling_strategies.html. The point I was raising was that&nbsp;by convention, the fit() method will overwrite the model parameters. The partial_fit() method, again by convention, allows updating (and thankfully, the sklearn maintainers are great about enforcing conventions).</p>\n<p>Also, you don't need to call fit() the first time, there's a check in partial_fit() to&nbsp;handle&nbsp;newly initialized instances.</p>\n<p>Cheers,</p>\n<p>- Emanuel</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57234,
      "author_name": "jamesdlawrence",
      "author_url": "",
      "post_date": "11/03/2014 09:18:58",
      "content": "<p>@skwalas, not if the connection is opened in mode &quot;r&quot;. If it was opened in another mode, that would be true.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 57385,
      "author_name": "",
      "author_url": "",
      "post_date": "11/06/2014 05:52:06",
      "content": "<p>[quote=Nicholas Guttenberg;56831]</p>\n<p>The data size is a bit of a problem for me too. I think there are a couple reasonable ways to proceed, but I guess we'll see what works best.&nbsp;</p>\n<p>One way is to use exclusively 'online learners' that can just take new data rows one at a time. In that case, you never have to load the entire thing into memory at once. This is a little limiting as far as what kinds of algorithms you can use, but this seems to be a pretty active area of development so you can find a bunch of research papers making online versions of stuff. The downside here is that this could mean a lot of custom implementation, which slows down one's ability to try a bunch of possibilities without committing too much time until they pan out.</p>\n<p>The other way, which seemed like a better bet to me, is to split the data up into smaller chunks and then ensemble the results. Since there's a good chunk of data, it means you can do a lot more with hold-out sets/etc than you could in a more data-starved case, so some techniques that'd otherwise be prone to over-fitting might be feasible here. If nothing else, this is probably a good first thing to do just to get a feeling for what class of algorithms are performing best with this data-set, before looking into writing up online versions of those things.</p>\n<p>[/quote]</p>\n<p>Yet another way, is to buy* a giant server with 32 gigabytes memory.</p>\n\n<p>*Or rent one on AWS.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "56815": "",
    "56816": "",
    "56819": "",
    "56824": "",
    "56826": "",
    "56828": "",
    "56829": "",
    "56830": "",
    "56831": "",
    "56832": "",
    "57058": "",
    "57084": "",
    "57096": "",
    "57098": "",
    "57099": "",
    "57100": "",
    "57101": "",
    "57111": "",
    "57117": "",
    "57127": "",
    "57128": "",
    "57131": "",
    "57136": "",
    "57141": "",
    "57143": "",
    "57234": "",
    "57385": ""
  },
  "source": "meta"
}