{
  "id": 14292,
  "title": "R, file size, and speed",
  "url": "/competitions/facebook-recruiting-iv-human-or-bot/discussion/14292",
  "author_name": "",
  "post_date": "2015-05-19T00:17:45.650Z",
  "votes": 3,
  "comment_count": 12,
  "views": 2154,
  "content": "<p>Hey everyone -</p>\n\n<p>I'm an R user relatively new to modeling and prediction. I love Kaggle for the exposure to new problems, data set and just general practice. However, I struggle when the sets get large. My R session just times out or just takes so long.&nbsp;</p>\n\n<p>Are there techical tips that anyone can share to help working with large sets? I'm looking into resources like H2O and even server based solutions but I'm a little lost there. &nbsp;</p>\n<p>I've managed to create one model (actually a couple leading to one submission) that's done reasonably well. I just want to continuing exploring different approaches. It's just very taxing on my machine apparently and I'm getting frustrated.</p>\n\n<p>Id love to hear about whatever tips anyone may have! Thanks!</p>",
  "messages": [
    {
      "id": "79052",
      "postDate": "05/19/2015 00:17:45",
      "content": "<p>Hey everyone -</p>\n\n<p>I'm an R user relatively new to modeling and prediction. I love Kaggle for the exposure to new problems, data set and just general practice. However, I struggle when the sets get large. My R session just times out or just takes so long.&nbsp;</p>\n\n<p>Are there techical tips that anyone can share to help working with large sets? I'm looking into resources like H2O and even server based solutions but I'm a little lost there. &nbsp;</p>\n<p>I've managed to create one model (actually a couple leading to one submission) that's done reasonably well. I just want to continuing exploring different approaches. It's just very taxing on my machine apparently and I'm getting frustrated.</p>\n\n<p>Id love to hear about whatever tips anyone may have! Thanks!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "79169",
      "postDate": "05/19/2015 07:00:55",
      "content": "<p>Hi Andrew,</p>\n<p>I use Hadoop on Azure (HDInsight) to load the large data set in, then I use HIVE queries to extract the data I need. Not sure if it's the best solution, but it's relatively fast (1-2 mins or less per query), and HIVE queries are a lot like SQL, which I am fairly comfortable with.</p>\n<p>I am sure there are comparable solutions out there on all other cloud vendors - but Azure happens to come with my Visual Studio Ultimate and it has a&nbsp;30-day trial too - just don't forget to shut down the cluster when done for the day :)</p>\n<p>Hope this helps a bit,</p>\n<p>Eugene</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "79203",
      "postDate": "05/19/2015 09:21:04",
      "content": "<p>I see two choices:</p>\n<p>First, you can use databases, and use SQL to manipulate your data.</p>\n<p>Second, use some programming language and you can do it all on your own. For this particular competition, you can sort the data by bidder_id, and then you can read the data row by row, compare the current row's bidder_id with last row's bidder_id. And then combine them if they have same bidder_id, create a new one otherwise</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "79206",
      "postDate": "05/19/2015 09:32:37",
      "content": "<p>Just for this case, I think using vectorization can solve lots of performance problems.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "79234",
      "postDate": "05/19/2015 12:38:47",
      "content": "<p>@Jiming Ye, what kind of program are you using for this competition ?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "79251",
      "postDate": "05/19/2015 14:02:47",
      "content": "<p>I work with R only on this competition.&nbsp;I keep the memory clean by using rm() and gc() constantly. Once model is built I remove all objects except necessary for prediction.&nbsp;</p>\n<p>I use Linux 8GB RAM and Mac 8GB RAM.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "79256",
      "postDate": "05/19/2015 14:31:33",
      "content": "<p>@Dzidas, In your opinion, what is the main factor for this competition ?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "79261",
      "postDate": "05/19/2015 14:47:25",
      "content": "<p>Please define &quot;main factor&quot; - are you after main difficulty, feature, etc.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "79316",
      "postDate": "05/19/2015 19:21:53",
      "content": "<p>You can read large datasets in R, and this one is not that large. Just use data.table package and its excellent fread function. On my laptop (8GB of RAM) I can read bids.csv file in 40 seconds.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "79349",
      "postDate": "05/19/2015 21:09:35",
      "content": "<p>Thanks for the ideas and responses everyone. @vk.net. It's not so much the reading in that I'm struggling with. I'm doing it the way you suggest. It's super fast ... Especially compared to just read.csv().&nbsp;</p>\n<p>My system is struggling when building and running the models. I've tried some sampling strategies.... Sort of some custom bagging methods if you will and it just doesn't seem very efficient.&nbsp;</p>\n<p>I've also tried storing in MySQL and just reading in just samples so I'm not storing as much in mem &nbsp;I've gotten mixed results.&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "79535",
      "postDate": "05/20/2015 22:20:31",
      "content": "<p>I am using a &quot;poor man's approach&quot; to this problem. I have a very old (but funcional) laptop (Dell D830) with 4 GB RAM.</p>\n<p>I created a&nbsp;<a href=\"https://www.sqlite.org/\">SQLite database</a> and loaded the three .csv data files into it, in different tables. I then created the necessary queries for feature extraction.</p>\n<p>Overall, the system is not incredibly fast, but I get my features matrix in about 5 minutes, including time employed by R in some internal calculations and more aggregations (there's only so much one can do with SQLite, but that's enough).</p>\n<p>I tried reading the whole file into memory, but this approach is much more manageable.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "79541",
      "postDate": "05/20/2015 22:55:21",
      "content": "<p>That's why I use MATLAB. The DATASTORE object in it allows manipulation of parts of data as needed, keeping the memory light, and processing fast.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "79669",
      "postDate": "05/21/2015 20:32:00",
      "content": "<p>I've been using dplyr to do data maniupulations, joins, etc. No problems at all on my older Windows laptop with 8GB RAM. The&nbsp;dplyr package&nbsp;works similar to SQL, and you don't have to setup any data connections.</p>\n<p>Good luck</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 79169,
      "author_name": "ivanko",
      "author_url": "",
      "post_date": "05/19/2015 07:00:55",
      "content": "<p>Hi Andrew,</p>\n<p>I use Hadoop on Azure (HDInsight) to load the large data set in, then I use HIVE queries to extract the data I need. Not sure if it's the best solution, but it's relatively fast (1-2 mins or less per query), and HIVE queries are a lot like SQL, which I am fairly comfortable with.</p>\n<p>I am sure there are comparable solutions out there on all other cloud vendors - but Azure happens to come with my Visual Studio Ultimate and it has a&nbsp;30-day trial too - just don't forget to shut down the cluster when done for the day :)</p>\n<p>Hope this helps a bit,</p>\n<p>Eugene</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 79203,
      "author_name": "yejiming",
      "author_url": "",
      "post_date": "05/19/2015 09:21:04",
      "content": "<p>I see two choices:</p>\n<p>First, you can use databases, and use SQL to manipulate your data.</p>\n<p>Second, use some programming language and you can do it all on your own. For this particular competition, you can sort the data by bidder_id, and then you can read the data row by row, compare the current row's bidder_id with last row's bidder_id. And then combine them if they have same bidder_id, create a new one otherwise</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 79206,
      "author_name": "patriczhao",
      "author_url": "",
      "post_date": "05/19/2015 09:32:37",
      "content": "<p>Just for this case, I think using vectorization can solve lots of performance problems.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 79234,
      "author_name": "mongolia",
      "author_url": "",
      "post_date": "05/19/2015 12:38:47",
      "content": "<p>@Jiming Ye, what kind of program are you using for this competition ?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 79251,
      "author_name": "dzidas",
      "author_url": "",
      "post_date": "05/19/2015 14:02:47",
      "content": "<p>I work with R only on this competition.&nbsp;I keep the memory clean by using rm() and gc() constantly. Once model is built I remove all objects except necessary for prediction.&nbsp;</p>\n<p>I use Linux 8GB RAM and Mac 8GB RAM.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 79256,
      "author_name": "mongolia",
      "author_url": "",
      "post_date": "05/19/2015 14:31:33",
      "content": "<p>@Dzidas, In your opinion, what is the main factor for this competition ?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 79261,
      "author_name": "dzidas",
      "author_url": "",
      "post_date": "05/19/2015 14:47:25",
      "content": "<p>Please define &quot;main factor&quot; - are you after main difficulty, feature, etc.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 79316,
      "author_name": "vkuznet",
      "author_url": "",
      "post_date": "05/19/2015 19:21:53",
      "content": "<p>You can read large datasets in R, and this one is not that large. Just use data.table package and its excellent fread function. On my laptop (8GB of RAM) I can read bids.csv file in 40 seconds.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 79349,
      "author_name": "andrewgeisler",
      "author_url": "",
      "post_date": "05/19/2015 21:09:35",
      "content": "<p>Thanks for the ideas and responses everyone. @vk.net. It's not so much the reading in that I'm struggling with. I'm doing it the way you suggest. It's super fast ... Especially compared to just read.csv().&nbsp;</p>\n<p>My system is struggling when building and running the models. I've tried some sampling strategies.... Sort of some custom bagging methods if you will and it just doesn't seem very efficient.&nbsp;</p>\n<p>I've also tried storing in MySQL and just reading in just samples so I'm not storing as much in mem &nbsp;I've gotten mixed results.&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 79535,
      "author_name": "rinzewind",
      "author_url": "",
      "post_date": "05/20/2015 22:20:31",
      "content": "<p>I am using a &quot;poor man's approach&quot; to this problem. I have a very old (but funcional) laptop (Dell D830) with 4 GB RAM.</p>\n<p>I created a&nbsp;<a href=\"https://www.sqlite.org/\">SQLite database</a> and loaded the three .csv data files into it, in different tables. I then created the necessary queries for feature extraction.</p>\n<p>Overall, the system is not incredibly fast, but I get my features matrix in about 5 minutes, including time employed by R in some internal calculations and more aggregations (there's only so much one can do with SQLite, but that's enough).</p>\n<p>I tried reading the whole file into memory, but this approach is much more manageable.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 79541,
      "author_name": "rawalc",
      "author_url": "",
      "post_date": "05/20/2015 22:55:21",
      "content": "<p>That's why I use MATLAB. The DATASTORE object in it allows manipulation of parts of data as needed, keeping the memory light, and processing fast.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 79669,
      "author_name": "jeffhebert",
      "author_url": "",
      "post_date": "05/21/2015 20:32:00",
      "content": "<p>I've been using dplyr to do data maniupulations, joins, etc. No problems at all on my older Windows laptop with 8GB RAM. The&nbsp;dplyr package&nbsp;works similar to SQL, and you don't have to setup any data connections.</p>\n<p>Good luck</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "79052": "",
    "79169": "",
    "79203": "",
    "79206": "",
    "79234": "",
    "79251": "",
    "79256": "",
    "79261": "",
    "79316": "",
    "79349": "",
    "79535": "",
    "79541": "",
    "79669": ""
  },
  "source": "meta"
}