{
  "id": 21787,
  "title": "Handling the large datasets",
  "url": "/competitions/grupo-bimbo-inventory-demand/discussion/21787",
  "author_name": "martinelli",
  "post_date": "2016-06-19T20:33:31.017000",
  "votes": 0,
  "comment_count": 25,
  "views": 4827,
  "content": "<p>train.csv is too large to handle entirely in my computer, so I have split it into a sample of 500,000 random rows (I know I could split using other logic, like using only the last weeks input, for example).</p>\n\n<p>My question is, how will I fit my models if my computer can't handle the entire dataset? Is there a function in Sklearn to fit data in increments?</p>",
  "messages": [
    {
      "id": 124937,
      "postDate": "2016-06-23T16:52:38.627Z",
      "content": "<p>You can dramatically reduce the memory usage if you are using pandas dataframes by using the dtype parameter in <code>read_csv()</code>. For example you can use np.int8 for the week values (Semana), since the maximum value is 9. I believe that pandas automatically sets each data type to np.float64. All of the columns can be set to np.int32, np.float32, or smaller. If you have at leas 8gb of memory, the entire training set should fit with the proper type assignment.</p>",
      "rawMarkdown": "You can dramatically reduce the memory usage if you are using pandas dataframes by using the dtype parameter in `read_csv()`. For example you can use np.int8 for the week values (Semana), since the maximum value is 9. I believe that pandas automatically sets each data type to np.float64. All of the columns can be set to np.int32, np.float32, or smaller. If you have at leas 8gb of memory, the entire training set should fit with the proper type assignment.",
      "votes": 7
    },
    {
      "id": 125065,
      "postDate": "2016-06-25T09:29:20.450Z",
      "content": "<p>Using dtypes is indeed a good idea.  Just beware that customer id will still require 64 bits.  Here is the code I use FYI:</p>\n\n<pre><code>train = pd.read_csv('Data/train.csv', \n                    dtype  = {'Semana' : 'int32',\n                              'Agencia_ID' :'int32',\n                              'Canal_ID' : 'int32',\n                              'Ruta_SAK' : 'int32',\n                              'Cliente-ID' : 'int64',\n                              'Producto_ID':'int32',\n                              'Venta_hoy':'float32',\n                              'Venta_uni_hoy': 'int32',\n                              'Dev_uni_proxima':'int32',\n                              'Dev_proxima':'float32',\n                              'Demanda_uni_equil':'int32'})\n</code></pre>\n\n<p>As said above, you can certianly do even better by using int8 in some places instead of int32.</p>",
      "rawMarkdown": "Using dtypes is indeed a good idea.  Just beware that customer id will still require 64 bits.  Here is the code I use FYI:\r\n\r\n    train = pd.read_csv('Data/train.csv', \r\n                        dtype  = {'Semana' : 'int32',\r\n                                  'Agencia_ID' :'int32',\r\n                                  'Canal_ID' : 'int32',\r\n                                  'Ruta_SAK' : 'int32',\r\n                                  'Cliente-ID' : 'int64',\r\n                                  'Producto_ID':'int32',\r\n                                  'Venta_hoy':'float32',\r\n                                  'Venta_uni_hoy': 'int32',\r\n                                  'Dev_uni_proxima':'int32',\r\n                                  'Dev_proxima':'float32',\r\n                                  'Demanda_uni_equil':'int32'})\r\n\r\nAs said above, you can certianly do even better by using int8 in some places instead of int32.\r\n",
      "votes": 5
    },
    {
      "id": 124964,
      "postDate": "2016-06-23T23:27:55.010Z",
      "content": "<p>You can definitely use pandas and scikit learn or xgboost for huge data.</p>\n\n<p>You can use the <code>chunksize</code> argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the <code>warmstart</code> option in sklearn. I think xgboost will do a warmstart if you repeatedly call <code>fit</code></p>",
      "rawMarkdown": "You can definitely use pandas and scikit learn or xgboost for huge data.\r\n\r\nYou can use the `chunksize` argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the `warmstart` option in sklearn. I think xgboost will do a warmstart if you repeatedly call `fit`",
      "votes": 4
    },
    {
      "id": 125486,
      "postDate": "2016-06-29T22:04:45.793Z",
      "content": "<p>@scirpus.  I was thinking the same, libffm is next on my list.</p>",
      "rawMarkdown": "@scirpus.  I was thinking the same, libffm is next on my list.",
      "votes": 1
    },
    {
      "id": 125443,
      "postDate": "2016-06-29T13:56:48.663Z",
      "content": "<p>[quote=leexiongan;125441]</p>\n\n<p>[quote=EZ;124964]</p>\n\n<p>You can definitely use pandas and scikit learn or xgboost for huge data.</p>\n\n<p>You can use the <code>chunksize</code> argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the <code>warmstart</code> option in sklearn. I think xgboost will do a warmstart if you repeatedly call <code>fit</code></p>\n\n<p>[/quote]</p>\n\n<p>Do you know anywhere that explains how to use xgboost in chunks or batch data?\nI can't seem it :(</p>\n\n<p>[/quote]</p>\n\n<p>No, Sorry, I just looked again, XGBoost doesn't support that. If you need that you'll need to use an algorithm that supports partial fitting. Many of the SKLearn models do support it as does most Neural networks ;-)</p>",
      "rawMarkdown": "[quote=leexiongan;125441]\r\n\r\n[quote=EZ;124964]\r\n\r\nYou can definitely use pandas and scikit learn or xgboost for huge data.\r\n\r\nYou can use the `chunksize` argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the `warmstart` option in sklearn. I think xgboost will do a warmstart if you repeatedly call `fit`\r\n\r\n[/quote]\r\n\r\n\r\nDo you know anywhere that explains how to use xgboost in chunks or batch data?\r\nI can't seem it :(\r\n\r\n[/quote]\r\n\r\nNo, Sorry, I just looked again, XGBoost doesn't support that. If you need that you'll need to use an algorithm that supports partial fitting. Many of the SKLearn models do support it as does most Neural networks ;-)\r\n",
      "votes": 1
    },
    {
      "id": 125091,
      "postDate": "2016-06-25T16:58:54.893Z",
      "content": "<p>Are you sure Cliente_Id requires 64 bits? My largest seems to be 2,015,152,015, which is smaller than largest int32 (2,147,483,647).</p>\n\n<p>/mattias</p>",
      "rawMarkdown": "Are you sure Cliente_Id requires 64 bits? My largest seems to be 2,015,152,015, which is smaller than largest int32 (2,147,483,647).\r\n\r\n/mattias",
      "votes": 1
    },
    {
      "id": 124865,
      "postDate": "2016-06-22T20:29:14.747Z",
      "content": "<p>[quote=Cookie;124598]</p>\n\n<p>Hi. First time I'm handling such a big dataset in R. There are close to 1M ClientsIDs (factors). How do you guys model that many factors? 1-hot encode of a million ClientIDs seems unbelievable... I may downsample the train set but I definitely need all from the test set. </p>\n\n<p>Appreciate any advise offered. Thanx</p>\n\n<p>[/quote]</p>\n\n<p>What we did in another competition was calculate the relevant metric per ID (so in this case, mean returns per client id) and the substitute the id for this value. When you create dummy variables for the levels you are basically working under the assumptions that the return rate differs between clients. This is more or less a shortcut (with some information loss) but better than not including it at all.</p>\n\n<p>You should do this separately for your training and test set as to not include information you would not normally have. You also need to be able to deal with unseen client ids. we simply imputed the median in those cases.</p>",
      "rawMarkdown": "[quote=Cookie;124598]\r\n\r\nHi. First time I'm handling such a big dataset in R. There are close to 1M ClientsIDs (factors). How do you guys model that many factors? 1-hot encode of a million ClientIDs seems unbelievable... I may downsample the train set but I definitely need all from the test set. \r\n\r\nAppreciate any advise offered. Thanx\r\n\r\n[/quote]\r\n\r\nWhat we did in another competition was calculate the relevant metric per ID (so in this case, mean returns per client id) and the substitute the id for this value. When you create dummy variables for the levels you are basically working under the assumptions that the return rate differs between clients. This is more or less a shortcut (with some information loss) but better than not including it at all.\r\n \r\nYou should do this separately for your training and test set as to not include information you would not normally have. You also need to be able to deal with unseen client ids. we simply imputed the median in those cases.",
      "votes": 1
    },
    {
      "id": 124557,
      "postDate": "2016-06-19T22:53:16.237Z",
      "content": "<p>You should try vowpal wabbit.. </p>",
      "rawMarkdown": "You should try vowpal wabbit.. ",
      "votes": 2
    },
    {
      "id": 124555,
      "postDate": "2016-06-19T22:37:39.100Z",
      "content": "<p>There are some algorithms available for incremental/online-learning in sklearn: <a href=\"http://scikit-learn.org/stable/modules/scaling_strategies.html#incremental-learning\">docs</a>.</p>",
      "rawMarkdown": "There are some algorithms available for incremental/online-learning in sklearn: [docs][1].\r\n\r\n\r\n  [1]: http://scikit-learn.org/stable/modules/scaling_strategies.html#incremental-learning",
      "votes": 2
    },
    {
      "id": 125482,
      "postDate": "2016-06-29T21:28:58.647Z",
      "content": "<p>is there some &quot;dtype&quot; for R language? or some way to optimize factors?</p>",
      "rawMarkdown": "is there some \"dtype\" for R language? or some way to optimize factors?"
    },
    {
      "id": 125472,
      "postDate": "2016-06-29T19:23:05.407Z",
      "content": "<p>I will be surprised if the leaders aren't using LibFFM - this requires a huge amount of memory usually - idle_speculation used it brilliantly in the Expedia competition and I quote - \n&quot;I built the model on a dual socket E5-2699v3 with ~700GB ram and was only able to use about half the bookings after '2014-07-01' due to memory limitations.&quot;</p>\n\n<p>Good luck!! </p>",
      "rawMarkdown": "I will be surprised if the leaders aren't using LibFFM - this requires a huge amount of memory usually - idle_speculation used it brilliantly in the Expedia competition and I quote - \r\n\"I built the model on a dual socket E5-2699v3 with ~700GB ram and was only able to use about half the bookings after '2014-07-01' due to memory limitations.\"\r\n\r\nGood luck!! "
    },
    {
      "id": 125464,
      "postDate": "2016-06-29T17:30:00.600Z",
      "content": "<p>I run the bare bone xgboost script for the whole data set. The memory requirement is only 30G. So don't let memory scare you out of this competition</p>",
      "rawMarkdown": "I run the bare bone xgboost script for the whole data set. The memory requirement is only 30G. So don't let memory scare you out of this competition"
    },
    {
      "id": 125451,
      "postDate": "2016-06-29T15:28:35.703Z",
      "content": "<p>xgboost has an out of core option, see </p>\n\n<p><a href=\"https://xgboost.readthedocs.io/en/latest//how_to/external_memory.html\">https://xgboost.readthedocs.io/en/latest//how_to/external_memory.html</a></p>\n\n<p>I haven't used it</p>",
      "rawMarkdown": "xgboost has an out of core option, see \r\n\r\nhttps://xgboost.readthedocs.io/en/latest//how_to/external_memory.html\r\n\r\nI haven't used it"
    },
    {
      "id": 125444,
      "postDate": "2016-06-29T14:12:13.560Z",
      "content": "<p>[quote=EZ;125443]</p>\n\n<p>[quote=leexiongan;125441]</p>\n\n<p>[quote=EZ;124964]</p>\n\n<p>You can definitely use pandas and scikit learn or xgboost for huge data.</p>\n\n<p>You can use the <code>chunksize</code> argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the <code>warmstart</code> option in sklearn. I think xgboost will do a warmstart if you repeatedly call <code>fit</code></p>\n\n<p>[/quote]</p>\n\n<p>Do you know anywhere that explains how to use xgboost in chunks or batch data?\nI can't seem it :(</p>\n\n<p>[/quote]</p>\n\n<p>No, Sorry, I just looked again, XGBoost doesn't support that. If you need that you'll need to use an algorithm that supports partial fitting. Many of the SKLearn models do support it as does most Neural networks ;-)</p>\n\n<p>[/quote]</p>\n\n<p>Think you can call xgboost's train with parameter xgb_model. Does that do the job?</p>",
      "rawMarkdown": "[quote=EZ;125443]\r\n\r\n[quote=leexiongan;125441]\r\n\r\n[quote=EZ;124964]\r\n\r\nYou can definitely use pandas and scikit learn or xgboost for huge data.\r\n\r\nYou can use the `chunksize` argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the `warmstart` option in sklearn. I think xgboost will do a warmstart if you repeatedly call `fit`\r\n\r\n[/quote]\r\n\r\n\r\nDo you know anywhere that explains how to use xgboost in chunks or batch data?\r\nI can't seem it :(\r\n\r\n[/quote]\r\n\r\nNo, Sorry, I just looked again, XGBoost doesn't support that. If you need that you'll need to use an algorithm that supports partial fitting. Many of the SKLearn models do support it as does most Neural networks ;-)\r\n\r\n\r\n[/quote]\r\n\r\nThink you can call xgboost's train with parameter xgb_model. Does that do the job?"
    },
    {
      "id": 125441,
      "postDate": "2016-06-29T13:47:50.817Z",
      "content": "<p>[quote=EZ;124964]</p>\n\n<p>You can definitely use pandas and scikit learn or xgboost for huge data.</p>\n\n<p>You can use the <code>chunksize</code> argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the <code>warmstart</code> option in sklearn. I think xgboost will do a warmstart if you repeatedly call <code>fit</code></p>\n\n<p>[/quote]</p>\n\n<p>Do you know anywhere that explains how to use xgboost in chunks or batch data?\nI can't seem it :(</p>",
      "rawMarkdown": "[quote=EZ;124964]\r\n\r\nYou can definitely use pandas and scikit learn or xgboost for huge data.\r\n\r\nYou can use the `chunksize` argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the `warmstart` option in sklearn. I think xgboost will do a warmstart if you repeatedly call `fit`\r\n\r\n[/quote]\r\n\r\n\r\nDo you know anywhere that explains how to use xgboost in chunks or batch data?\r\nI can't seem it :("
    },
    {
      "id": 125094,
      "postDate": "2016-06-25T19:29:52.870Z",
      "content": "<p>Mattias, you are right :)</p>",
      "rawMarkdown": "Mattias, you are right :)"
    },
    {
      "id": 124966,
      "postDate": "2016-06-23T23:30:50.850Z",
      "content": "<p>[quote=Kevin Kirchhoff;124937]</p>\n\n<p>You can dramatically reduce the memory usage if you are using pandas dataframes by using the dtype parameter in <code>read_csv()</code>. For example you can use np.int8 for the week values (Semana), since the maximum value is 9. I believe that pandas automatically sets each data type to np.float64. All of the columns can be set to np.int32, np.float32, or smaller. If you have at leas 8gb of memory, the entire training set should fit with the proper type assignment.</p>\n\n<p>[/quote]</p>\n\n<p>Great idea! Thank you</p>",
      "rawMarkdown": "[quote=Kevin Kirchhoff;124937]\r\n\r\nYou can dramatically reduce the memory usage if you are using pandas dataframes by using the dtype parameter in `read_csv()`. For example you can use np.int8 for the week values (Semana), since the maximum value is 9. I believe that pandas automatically sets each data type to np.float64. All of the columns can be set to np.int32, np.float32, or smaller. If you have at leas 8gb of memory, the entire training set should fit with the proper type assignment.\r\n\r\n[/quote]\r\n\r\nGreat idea! Thank you"
    },
    {
      "id": 124965,
      "postDate": "2016-06-23T23:29:15.063Z",
      "content": "<p>[quote=EZ;124964]</p>\n\n<p>You can definitely use pandas and scikit learn or xgboost for huge data.</p>\n\n<p>You can use the <code>chunksize</code> argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the <code>warmstart</code> option in sklearn. I think xgboost will do a warmstart if you repeatedly call <code>fit</code></p>\n\n<p>[/quote]</p>\n\n<p>Thanks! Yes, I just learned this earlier in the week. It does in fact make a huge difference!</p>",
      "rawMarkdown": "[quote=EZ;124964]\r\n\r\nYou can definitely use pandas and scikit learn or xgboost for huge data.\r\n\r\nYou can use the `chunksize` argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the `warmstart` option in sklearn. I think xgboost will do a warmstart if you repeatedly call `fit`\r\n\r\n[/quote]\r\n\r\nThanks! Yes, I just learned this earlier in the week. It does in fact make a huge difference!"
    },
    {
      "id": 124925,
      "postDate": "2016-06-23T14:45:37.533Z",
      "content": "<p>Hi Valentine. Thanks for sharing your experiences. Am working on your idea now  :-)</p>",
      "rawMarkdown": "Hi Valentine. Thanks for sharing your experiences. Am working on your idea now  :-)"
    },
    {
      "id": 124598,
      "postDate": "2016-06-20T08:22:18.223Z",
      "content": "<p>Hi. First time I'm handling such a big dataset in R. There are close to 1M ClientsIDs (factors). How do you guys model that many factors? 1-hot encode of a million ClientIDs seems unbelievable... I may downsample the train set but I definitely need all from the test set. </p>\n\n<p>Appreciate any advise offered. Thanx</p>",
      "rawMarkdown": "Hi. First time I'm handling such a big dataset in R. There are close to 1M ClientsIDs (factors). How do you guys model that many factors? 1-hot encode of a million ClientIDs seems unbelievable... I may downsample the train set but I definitely need all from the test set. \r\n\r\nAppreciate any advise offered. Thanx"
    },
    {
      "id": 124578,
      "postDate": "2016-06-20T03:54:05.543Z",
      "content": "<p>[quote=sschnug;124555]</p>\n\n<p>There are some algorithms available for incremental/online-learning in sklearn: <a href=\"http://scikit-learn.org/stable/modules/scaling_strategies.html#incremental-learning\">docs</a>.</p>\n\n<p>[/quote]</p>\n\n<p>This is very helpful, thanks!</p>",
      "rawMarkdown": "[quote=sschnug;124555]\r\n\r\nThere are some algorithms available for incremental/online-learning in sklearn: [docs][1].\r\n\r\n\r\n  [1]: http://scikit-learn.org/stable/modules/scaling_strategies.html#incremental-learning\r\n\r\n[/quote]\r\n\r\nThis is very helpful, thanks!"
    },
    {
      "id": 124577,
      "postDate": "2016-06-20T03:53:03.803Z",
      "content": "<p>[quote=FredR;124554]</p>\n\n<p>I don't believe it's possible.  The best you could do is do some feature engineering and reduce the content of your train set.  </p>\n\n<p>So maybe you only pull one or two labels and discard the rest.</p>\n\n<p>I had the same question and googling left me with &quot;calling fit multiple times will wipe out previous fit calls.&quot;</p>\n\n<p>However you can get pretty good results without even using scikitlearn or any machine learning algorithms at all on this data set.  At the moment I'm 219 out of 572 and I haven't used anything from scikit learn or xgboost.</p>\n\n<p>[/quote]</p>\n\n<p>That's good to know! I'm still doing some EDA but was already having trouble with the size of this dataset.</p>",
      "rawMarkdown": "[quote=FredR;124554]\r\n\r\nI don't believe it's possible.  The best you could do is do some feature engineering and reduce the content of your train set.  \r\n\r\nSo maybe you only pull one or two labels and discard the rest.\r\n\r\nI had the same question and googling left me with \"calling fit multiple times will wipe out previous fit calls.\"\r\n\r\n\r\nHowever you can get pretty good results without even using scikitlearn or any machine learning algorithms at all on this data set.  At the moment I'm 219 out of 572 and I haven't used anything from scikit learn or xgboost.\r\n\r\n[/quote]\r\n\r\nThat's good to know! I'm still doing some EDA but was already having trouble with the size of this dataset."
    },
    {
      "id": 124544,
      "postDate": "2016-06-19T20:33:31.017Z",
      "content": "<p>train.csv is too large to handle entirely in my computer, so I have split it into a sample of 500,000 random rows (I know I could split using other logic, like using only the last weeks input, for example).</p>\n\n<p>My question is, how will I fit my models if my computer can't handle the entire dataset? Is there a function in Sklearn to fit data in increments?</p>",
      "rawMarkdown": "train.csv is too large to handle entirely in my computer, so I have split it into a sample of 500,000 random rows (I know I could split using other logic, like using only the last weeks input, for example).\r\n\r\nMy question is, how will I fit my models if my computer can't handle the entire dataset? Is there a function in Sklearn to fit data in increments?"
    },
    {
      "id": 125138,
      "postDate": "2016-06-26T17:47:06.003Z",
      "rawMarkdown": "",
      "votes": 2,
      "isDeleted": true
    },
    {
      "id": 124556,
      "postDate": "2016-06-19T22:49:26.240Z",
      "rawMarkdown": "",
      "votes": 2,
      "isDeleted": true
    },
    {
      "id": 124554,
      "postDate": "2016-06-19T22:09:15.830Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 124937,
      "author_name": "Kevin Kirchhoff",
      "author_url": "",
      "post_date": "2016-06-23T16:52:38.627000",
      "content": "<p>You can dramatically reduce the memory usage if you are using pandas dataframes by using the dtype parameter in <code>read_csv()</code>. For example you can use np.int8 for the week values (Semana), since the maximum value is 9. I believe that pandas automatically sets each data type to np.float64. All of the columns can be set to np.int32, np.float32, or smaller. If you have at leas 8gb of memory, the entire training set should fit with the proper type assignment.</p>",
      "votes": 7,
      "replies": []
    },
    {
      "id": 125065,
      "author_name": "CPMP",
      "author_url": "",
      "post_date": "2016-06-25T09:29:20.450000",
      "content": "<p>Using dtypes is indeed a good idea.  Just beware that customer id will still require 64 bits.  Here is the code I use FYI:</p>\n\n<pre><code>train = pd.read_csv('Data/train.csv', \n                    dtype  = {'Semana' : 'int32',\n                              'Agencia_ID' :'int32',\n                              'Canal_ID' : 'int32',\n                              'Ruta_SAK' : 'int32',\n                              'Cliente-ID' : 'int64',\n                              'Producto_ID':'int32',\n                              'Venta_hoy':'float32',\n                              'Venta_uni_hoy': 'int32',\n                              'Dev_uni_proxima':'int32',\n                              'Dev_proxima':'float32',\n                              'Demanda_uni_equil':'int32'})\n</code></pre>\n\n<p>As said above, you can certianly do even better by using int8 in some places instead of int32.</p>",
      "votes": 5,
      "replies": []
    },
    {
      "id": 124964,
      "author_name": "EZ",
      "author_url": "",
      "post_date": "2016-06-23T23:27:55.010000",
      "content": "<p>You can definitely use pandas and scikit learn or xgboost for huge data.</p>\n\n<p>You can use the <code>chunksize</code> argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the <code>warmstart</code> option in sklearn. I think xgboost will do a warmstart if you repeatedly call <code>fit</code></p>",
      "votes": 4,
      "replies": []
    },
    {
      "id": 125486,
      "author_name": "CPMP",
      "author_url": "",
      "post_date": "2016-06-29T22:04:45.793000",
      "content": "<p>@scirpus.  I was thinking the same, libffm is next on my list.</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 125443,
      "author_name": "EZ",
      "author_url": "",
      "post_date": "2016-06-29T13:56:48.663000",
      "content": "<p>[quote=leexiongan;125441]</p>\n\n<p>[quote=EZ;124964]</p>\n\n<p>You can definitely use pandas and scikit learn or xgboost for huge data.</p>\n\n<p>You can use the <code>chunksize</code> argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the <code>warmstart</code> option in sklearn. I think xgboost will do a warmstart if you repeatedly call <code>fit</code></p>\n\n<p>[/quote]</p>\n\n<p>Do you know anywhere that explains how to use xgboost in chunks or batch data?\nI can't seem it :(</p>\n\n<p>[/quote]</p>\n\n<p>No, Sorry, I just looked again, XGBoost doesn't support that. If you need that you'll need to use an algorithm that supports partial fitting. Many of the SKLearn models do support it as does most Neural networks ;-)</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 125091,
      "author_name": "Mattias Fagerlund",
      "author_url": "",
      "post_date": "2016-06-25T16:58:54.893000",
      "content": "<p>Are you sure Cliente_Id requires 64 bits? My largest seems to be 2,015,152,015, which is smaller than largest int32 (2,147,483,647).</p>\n\n<p>/mattias</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 124865,
      "author_name": "Valentin Zambelli",
      "author_url": "",
      "post_date": "2016-06-22T20:29:14.747000",
      "content": "<p>[quote=Cookie;124598]</p>\n\n<p>Hi. First time I'm handling such a big dataset in R. There are close to 1M ClientsIDs (factors). How do you guys model that many factors? 1-hot encode of a million ClientIDs seems unbelievable... I may downsample the train set but I definitely need all from the test set. </p>\n\n<p>Appreciate any advise offered. Thanx</p>\n\n<p>[/quote]</p>\n\n<p>What we did in another competition was calculate the relevant metric per ID (so in this case, mean returns per client id) and the substitute the id for this value. When you create dummy variables for the levels you are basically working under the assumptions that the return rate differs between clients. This is more or less a shortcut (with some information loss) but better than not including it at all.</p>\n\n<p>You should do this separately for your training and test set as to not include information you would not normally have. You also need to be able to deal with unseen client ids. we simply imputed the median in those cases.</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 124557,
      "author_name": "Shahnawaz Akhtar",
      "author_url": "",
      "post_date": "2016-06-19T22:53:16.237000",
      "content": "<p>You should try vowpal wabbit.. </p>",
      "votes": 2,
      "replies": []
    },
    {
      "id": 124555,
      "author_name": "sschnug",
      "author_url": "",
      "post_date": "2016-06-19T22:37:39.100000",
      "content": "<p>There are some algorithms available for incremental/online-learning in sklearn: <a href=\"http://scikit-learn.org/stable/modules/scaling_strategies.html#incremental-learning\">docs</a>.</p>",
      "votes": 2,
      "replies": []
    },
    {
      "id": 125482,
      "author_name": "Antonio Flores",
      "author_url": "",
      "post_date": "2016-06-29T21:28:58.647000",
      "content": "<p>is there some &quot;dtype&quot; for R language? or some way to optimize factors?</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 125472,
      "author_name": "Scirpus",
      "author_url": "",
      "post_date": "2016-06-29T19:23:05.407000",
      "content": "<p>I will be surprised if the leaders aren't using LibFFM - this requires a huge amount of memory usually - idle_speculation used it brilliantly in the Expedia competition and I quote - \n&quot;I built the model on a dual socket E5-2699v3 with ~700GB ram and was only able to use about half the bookings after '2014-07-01' due to memory limitations.&quot;</p>\n\n<p>Good luck!! </p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 125464,
      "author_name": "Jialun He",
      "author_url": "",
      "post_date": "2016-06-29T17:30:00.600000",
      "content": "<p>I run the bare bone xgboost script for the whole data set. The memory requirement is only 30G. So don't let memory scare you out of this competition</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 125451,
      "author_name": "CPMP",
      "author_url": "",
      "post_date": "2016-06-29T15:28:35.703000",
      "content": "<p>xgboost has an out of core option, see </p>\n\n<p><a href=\"https://xgboost.readthedocs.io/en/latest//how_to/external_memory.html\">https://xgboost.readthedocs.io/en/latest//how_to/external_memory.html</a></p>\n\n<p>I haven't used it</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 125444,
      "author_name": "Sangxia",
      "author_url": "",
      "post_date": "2016-06-29T14:12:13.560000",
      "content": "<p>[quote=EZ;125443]</p>\n\n<p>[quote=leexiongan;125441]</p>\n\n<p>[quote=EZ;124964]</p>\n\n<p>You can definitely use pandas and scikit learn or xgboost for huge data.</p>\n\n<p>You can use the <code>chunksize</code> argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the <code>warmstart</code> option in sklearn. I think xgboost will do a warmstart if you repeatedly call <code>fit</code></p>\n\n<p>[/quote]</p>\n\n<p>Do you know anywhere that explains how to use xgboost in chunks or batch data?\nI can't seem it :(</p>\n\n<p>[/quote]</p>\n\n<p>No, Sorry, I just looked again, XGBoost doesn't support that. If you need that you'll need to use an algorithm that supports partial fitting. Many of the SKLearn models do support it as does most Neural networks ;-)</p>\n\n<p>[/quote]</p>\n\n<p>Think you can call xgboost's train with parameter xgb_model. Does that do the job?</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 125441,
      "author_name": "leexa",
      "author_url": "",
      "post_date": "2016-06-29T13:47:50.817000",
      "content": "<p>[quote=EZ;124964]</p>\n\n<p>You can definitely use pandas and scikit learn or xgboost for huge data.</p>\n\n<p>You can use the <code>chunksize</code> argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the <code>warmstart</code> option in sklearn. I think xgboost will do a warmstart if you repeatedly call <code>fit</code></p>\n\n<p>[/quote]</p>\n\n<p>Do you know anywhere that explains how to use xgboost in chunks or batch data?\nI can't seem it :(</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 125094,
      "author_name": "CPMP",
      "author_url": "",
      "post_date": "2016-06-25T19:29:52.870000",
      "content": "<p>Mattias, you are right :)</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 124966,
      "author_name": "martinelli",
      "author_url": "",
      "post_date": "2016-06-23T23:30:50.850000",
      "content": "<p>[quote=Kevin Kirchhoff;124937]</p>\n\n<p>You can dramatically reduce the memory usage if you are using pandas dataframes by using the dtype parameter in <code>read_csv()</code>. For example you can use np.int8 for the week values (Semana), since the maximum value is 9. I believe that pandas automatically sets each data type to np.float64. All of the columns can be set to np.int32, np.float32, or smaller. If you have at leas 8gb of memory, the entire training set should fit with the proper type assignment.</p>\n\n<p>[/quote]</p>\n\n<p>Great idea! Thank you</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 124965,
      "author_name": "martinelli",
      "author_url": "",
      "post_date": "2016-06-23T23:29:15.063000",
      "content": "<p>[quote=EZ;124964]</p>\n\n<p>You can definitely use pandas and scikit learn or xgboost for huge data.</p>\n\n<p>You can use the <code>chunksize</code> argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the <code>warmstart</code> option in sklearn. I think xgboost will do a warmstart if you repeatedly call <code>fit</code></p>\n\n<p>[/quote]</p>\n\n<p>Thanks! Yes, I just learned this earlier in the week. It does in fact make a huge difference!</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 124925,
      "author_name": "Cookie",
      "author_url": "",
      "post_date": "2016-06-23T14:45:37.533000",
      "content": "<p>Hi Valentine. Thanks for sharing your experiences. Am working on your idea now  :-)</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 124598,
      "author_name": "Cookie",
      "author_url": "",
      "post_date": "2016-06-20T08:22:18.223000",
      "content": "<p>Hi. First time I'm handling such a big dataset in R. There are close to 1M ClientsIDs (factors). How do you guys model that many factors? 1-hot encode of a million ClientIDs seems unbelievable... I may downsample the train set but I definitely need all from the test set. </p>\n\n<p>Appreciate any advise offered. Thanx</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 124578,
      "author_name": "martinelli",
      "author_url": "",
      "post_date": "2016-06-20T03:54:05.543000",
      "content": "<p>[quote=sschnug;124555]</p>\n\n<p>There are some algorithms available for incremental/online-learning in sklearn: <a href=\"http://scikit-learn.org/stable/modules/scaling_strategies.html#incremental-learning\">docs</a>.</p>\n\n<p>[/quote]</p>\n\n<p>This is very helpful, thanks!</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 124577,
      "author_name": "martinelli",
      "author_url": "",
      "post_date": "2016-06-20T03:53:03.803000",
      "content": "<p>[quote=FredR;124554]</p>\n\n<p>I don't believe it's possible.  The best you could do is do some feature engineering and reduce the content of your train set.  </p>\n\n<p>So maybe you only pull one or two labels and discard the rest.</p>\n\n<p>I had the same question and googling left me with &quot;calling fit multiple times will wipe out previous fit calls.&quot;</p>\n\n<p>However you can get pretty good results without even using scikitlearn or any machine learning algorithms at all on this data set.  At the moment I'm 219 out of 572 and I haven't used anything from scikit learn or xgboost.</p>\n\n<p>[/quote]</p>\n\n<p>That's good to know! I'm still doing some EDA but was already having trouble with the size of this dataset.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 125138,
      "author_name": "",
      "author_url": "",
      "post_date": "2016-06-26T17:47:06.003000",
      "content": "",
      "votes": 2,
      "replies": []
    },
    {
      "id": 124556,
      "author_name": "",
      "author_url": "",
      "post_date": "2016-06-19T22:49:26.240000",
      "content": "",
      "votes": 2,
      "replies": []
    },
    {
      "id": 124554,
      "author_name": "",
      "author_url": "",
      "post_date": "2016-06-19T22:09:15.830000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "124937": "You can dramatically reduce the memory usage if you are using pandas dataframes by using the dtype parameter in `read_csv()`. For example you can use np.int8 for the week values (Semana), since the maximum value is 9. I believe that pandas automatically sets each data type to np.float64. All of the columns can be set to np.int32, np.float32, or smaller. If you have at leas 8gb of memory, the entire training set should fit with the proper type assignment.",
    "125065": "Using dtypes is indeed a good idea.  Just beware that customer id will still require 64 bits.  Here is the code I use FYI:\r\n\r\n    train = pd.read_csv('Data/train.csv', \r\n                        dtype  = {'Semana' : 'int32',\r\n                                  'Agencia_ID' :'int32',\r\n                                  'Canal_ID' : 'int32',\r\n                                  'Ruta_SAK' : 'int32',\r\n                                  'Cliente-ID' : 'int64',\r\n                                  'Producto_ID':'int32',\r\n                                  'Venta_hoy':'float32',\r\n                                  'Venta_uni_hoy': 'int32',\r\n                                  'Dev_uni_proxima':'int32',\r\n                                  'Dev_proxima':'float32',\r\n                                  'Demanda_uni_equil':'int32'})\r\n\r\nAs said above, you can certianly do even better by using int8 in some places instead of int32.\r\n",
    "124964": "You can definitely use pandas and scikit learn or xgboost for huge data.\r\n\r\nYou can use the `chunksize` argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the `warmstart` option in sklearn. I think xgboost will do a warmstart if you repeatedly call `fit`",
    "125486": "@scirpus.  I was thinking the same, libffm is next on my list.",
    "125443": "[quote=leexiongan;125441]\r\n\r\n[quote=EZ;124964]\r\n\r\nYou can definitely use pandas and scikit learn or xgboost for huge data.\r\n\r\nYou can use the `chunksize` argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the `warmstart` option in sklearn. I think xgboost will do a warmstart if you repeatedly call `fit`\r\n\r\n[/quote]\r\n\r\n\r\nDo you know anywhere that explains how to use xgboost in chunks or batch data?\r\nI can't seem it :(\r\n\r\n[/quote]\r\n\r\nNo, Sorry, I just looked again, XGBoost doesn't support that. If you need that you'll need to use an algorithm that supports partial fitting. Many of the SKLearn models do support it as does most Neural networks ;-)\r\n",
    "125091": "Are you sure Cliente_Id requires 64 bits? My largest seems to be 2,015,152,015, which is smaller than largest int32 (2,147,483,647).\r\n\r\n/mattias",
    "124865": "[quote=Cookie;124598]\r\n\r\nHi. First time I'm handling such a big dataset in R. There are close to 1M ClientsIDs (factors). How do you guys model that many factors? 1-hot encode of a million ClientIDs seems unbelievable... I may downsample the train set but I definitely need all from the test set. \r\n\r\nAppreciate any advise offered. Thanx\r\n\r\n[/quote]\r\n\r\nWhat we did in another competition was calculate the relevant metric per ID (so in this case, mean returns per client id) and the substitute the id for this value. When you create dummy variables for the levels you are basically working under the assumptions that the return rate differs between clients. This is more or less a shortcut (with some information loss) but better than not including it at all.\r\n \r\nYou should do this separately for your training and test set as to not include information you would not normally have. You also need to be able to deal with unseen client ids. we simply imputed the median in those cases.",
    "124557": "You should try vowpal wabbit.. ",
    "124555": "There are some algorithms available for incremental/online-learning in sklearn: [docs][1].\r\n\r\n\r\n  [1]: http://scikit-learn.org/stable/modules/scaling_strategies.html#incremental-learning",
    "125482": "is there some \"dtype\" for R language? or some way to optimize factors?",
    "125472": "I will be surprised if the leaders aren't using LibFFM - this requires a huge amount of memory usually - idle_speculation used it brilliantly in the Expedia competition and I quote - \r\n\"I built the model on a dual socket E5-2699v3 with ~700GB ram and was only able to use about half the bookings after '2014-07-01' due to memory limitations.\"\r\n\r\nGood luck!! ",
    "125464": "I run the bare bone xgboost script for the whole data set. The memory requirement is only 30G. So don't let memory scare you out of this competition",
    "125451": "xgboost has an out of core option, see \r\n\r\nhttps://xgboost.readthedocs.io/en/latest//how_to/external_memory.html\r\n\r\nI haven't used it",
    "125444": "[quote=EZ;125443]\r\n\r\n[quote=leexiongan;125441]\r\n\r\n[quote=EZ;124964]\r\n\r\nYou can definitely use pandas and scikit learn or xgboost for huge data.\r\n\r\nYou can use the `chunksize` argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the `warmstart` option in sklearn. I think xgboost will do a warmstart if you repeatedly call `fit`\r\n\r\n[/quote]\r\n\r\n\r\nDo you know anywhere that explains how to use xgboost in chunks or batch data?\r\nI can't seem it :(\r\n\r\n[/quote]\r\n\r\nNo, Sorry, I just looked again, XGBoost doesn't support that. If you need that you'll need to use an algorithm that supports partial fitting. Many of the SKLearn models do support it as does most Neural networks ;-)\r\n\r\n\r\n[/quote]\r\n\r\nThink you can call xgboost's train with parameter xgb_model. Does that do the job?",
    "125441": "[quote=EZ;124964]\r\n\r\nYou can definitely use pandas and scikit learn or xgboost for huge data.\r\n\r\nYou can use the `chunksize` argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the `warmstart` option in sklearn. I think xgboost will do a warmstart if you repeatedly call `fit`\r\n\r\n[/quote]\r\n\r\n\r\nDo you know anywhere that explains how to use xgboost in chunks or batch data?\r\nI can't seem it :(",
    "125094": "Mattias, you are right :)",
    "124966": "[quote=Kevin Kirchhoff;124937]\r\n\r\nYou can dramatically reduce the memory usage if you are using pandas dataframes by using the dtype parameter in `read_csv()`. For example you can use np.int8 for the week values (Semana), since the maximum value is 9. I believe that pandas automatically sets each data type to np.float64. All of the columns can be set to np.int32, np.float32, or smaller. If you have at leas 8gb of memory, the entire training set should fit with the proper type assignment.\r\n\r\n[/quote]\r\n\r\nGreat idea! Thank you",
    "124965": "[quote=EZ;124964]\r\n\r\nYou can definitely use pandas and scikit learn or xgboost for huge data.\r\n\r\nYou can use the `chunksize` argument in pandas.read_csv, it gives you back an iterator, then you can process that chunk and use the `warmstart` option in sklearn. I think xgboost will do a warmstart if you repeatedly call `fit`\r\n\r\n[/quote]\r\n\r\nThanks! Yes, I just learned this earlier in the week. It does in fact make a huge difference!",
    "124925": "Hi Valentine. Thanks for sharing your experiences. Am working on your idea now  :-)",
    "124598": "Hi. First time I'm handling such a big dataset in R. There are close to 1M ClientsIDs (factors). How do you guys model that many factors? 1-hot encode of a million ClientIDs seems unbelievable... I may downsample the train set but I definitely need all from the test set. \r\n\r\nAppreciate any advise offered. Thanx",
    "124578": "[quote=sschnug;124555]\r\n\r\nThere are some algorithms available for incremental/online-learning in sklearn: [docs][1].\r\n\r\n\r\n  [1]: http://scikit-learn.org/stable/modules/scaling_strategies.html#incremental-learning\r\n\r\n[/quote]\r\n\r\nThis is very helpful, thanks!",
    "124577": "[quote=FredR;124554]\r\n\r\nI don't believe it's possible.  The best you could do is do some feature engineering and reduce the content of your train set.  \r\n\r\nSo maybe you only pull one or two labels and discard the rest.\r\n\r\nI had the same question and googling left me with \"calling fit multiple times will wipe out previous fit calls.\"\r\n\r\n\r\nHowever you can get pretty good results without even using scikitlearn or any machine learning algorithms at all on this data set.  At the moment I'm 219 out of 572 and I haven't used anything from scikit learn or xgboost.\r\n\r\n[/quote]\r\n\r\nThat's good to know! I'm still doing some EDA but was already having trouble with the size of this dataset.",
    "124544": "train.csv is too large to handle entirely in my computer, so I have split it into a sample of 500,000 random rows (I know I could split using other logic, like using only the last weeks input, for example).\r\n\r\nMy question is, how will I fit my models if my computer can't handle the entire dataset? Is there a function in Sklearn to fit data in increments?",
    "125138": "",
    "124556": "",
    "124554": ""
  }
}