{
  "id": 79526,
  "title": "How to deal with Memory error?",
  "url": "/competitions/elo-merchant-category-recommendation/discussion/79526",
  "author_name": "Ibtesam Ahmed",
  "post_date": "2019-02-05T05:19:28.842000",
  "votes": 10,
  "comment_count": 21,
  "views": 0,
  "content": "<p>Due to the length of the code or extra features added during feature engineering , my kernel is restarting again and again(all the 14GB RAM space gets used up).I've seen people have more features than mine and their kernels seems to run just fine.</p>\n\n<p>Any suggestions to fix this would help!</p>\n\n<p>Thanks</p>",
  "messages": [
    {
      "id": 783090,
      "postDate": "2020-03-23T01:41:12.247Z",
      "content": "<p>I said to use pyspark because you can store your features in their database instead of locally, you can even run your ml calculations in their cloud system. So I don't understand why you down voted me.</p>",
      "rawMarkdown": "I said to use pyspark because you can store your features in their database instead of locally, you can even run your ml calculations in their cloud system. So I don't understand why you down voted me.",
      "votes": 5
    },
    {
      "id": 466314,
      "postDate": "2019-02-05T05:19:28.843Z",
      "content": "<p>Due to the length of the code or extra features added during feature engineering , my kernel is restarting again and again(all the 14GB RAM space gets used up).I've seen people have more features than mine and their kernels seems to run just fine.</p>\n\n<p>Any suggestions to fix this would help!</p>\n\n<p>Thanks</p>",
      "rawMarkdown": "Due to the length of the code or extra features added during feature engineering , my kernel is restarting again and again(all the 14GB RAM space gets used up).I've seen people have more features than mine and their kernels seems to run just fine.\n\nAny suggestions to fix this would help!\n\nThanks",
      "votes": 10
    },
    {
      "id": 468661,
      "postDate": "2019-02-09T12:03:05.533Z",
      "content": "<p>Hi, if you are using pandas.read_csv function, set the parameters iterator=True and chunksize to a reasonable value to iterate lazily instead of reading the whole file into memory.</p>\n\n<p>Example:</p>\n\n<pre><code>train = pd.read_csv('train.csv', iterator=True, chunksize=100_000, dtype={'x': np.int16, 'y': np.float64})\nX_train = pd.DataFrame()\ny_train = pd.Series()\n\nfor df in train:\n    X_train = X_train.append(your_feature_engineering_function(df))\n    y_train = y_train.append(pd.Series(df['y'].values[-1]))\n    # this does feature engineering per chunk\n</code></pre>\n\n<p>Hope this is helpful.</p>",
      "rawMarkdown": "Hi, if you are using pandas.read_csv function, set the parameters iterator=True and chunksize to a reasonable value to iterate lazily instead of reading the whole file into memory.\n\nExample:\n\n    train = pd.read_csv('train.csv', iterator=True, chunksize=100_000, dtype={'x': np.int16, 'y': np.float64})\n    X_train = pd.DataFrame()\n    y_train = pd.Series()\n\n    for df in train:\n        X_train = X_train.append(your_feature_engineering_function(df))\n        y_train = y_train.append(pd.Series(df['y'].values[-1]))\n        # this does feature engineering per chunk\n\nHope this is helpful.",
      "votes": 7
    },
    {
      "id": 468017,
      "postDate": "2019-02-08T06:24:30.373Z",
      "content": "<p>I found this piece of code in one of the kernels (I don't remember, sorry) but it really helps get rid of memory errors by choosing the right data type I think.\nYou can just call this, like <code>new_df= reduce_mem_usage(new_df)</code> etc.</p>\n\n<pre><code>def reduce_mem_usage(df, verbose=True):\n    numerics = ['int16', 'int32', 'int64', 'float16', 'float32', 'float64']\n    start_mem = df.memory_usage().sum() / 1024**2    \n    for col in df.columns:\n        col_type = df[col].dtypes\n        if col_type in numerics:\n            c_min = df[col].min()\n            c_max = df[col].max()\n            if str(col_type)[:3] == 'int':\n                if c_min &gt; np.iinfo(np.int8).min and c_max &lt; np.iinfo(np.int8).max:\n                    df[col] = df[col].astype(np.int8)\n                elif c_min &gt; np.iinfo(np.int16).min and c_max &lt; np.iinfo(np.int16).max:\n                    df[col] = df[col].astype(np.int16)\n                elif c_min &gt; np.iinfo(np.int32).min and c_max &lt; np.iinfo(np.int32).max:\n                    df[col] = df[col].astype(np.int32)\n                elif c_min &gt; np.iinfo(np.int64).min and c_max &lt; np.iinfo(np.int64).max:\n                    df[col] = df[col].astype(np.int64)  \n            else:\n                if c_min &gt; np.finfo(np.float16).min and c_max &lt; np.finfo(np.float16).max:\n                    df[col] = df[col].astype(np.float16)\n                elif c_min &gt; np.finfo(np.float32).min and c_max &lt; np.finfo(np.float32).max:\n                    df[col] = df[col].astype(np.float32)\n                else:\n                    df[col] = df[col].astype(np.float64)    \n    end_mem = df.memory_usage().sum() / 1024**2\n    if verbose: print('Mem. usage decreased to {:5.2f} Mb ({:.1f}% reduction)'.format(end_mem, 100 * (start_mem - end_mem) / start_mem))\n    return df\n</code></pre>",
      "rawMarkdown": "I found this piece of code in one of the kernels (I don't remember, sorry) but it really helps get rid of memory errors by choosing the right data type I think.\nYou can just call this, like `new_df= reduce_mem_usage(new_df)` etc.\n\n    def reduce_mem_usage(df, verbose=True):\n        numerics = ['int16', 'int32', 'int64', 'float16', 'float32', 'float64']\n        start_mem = df.memory_usage().sum() / 1024**2    \n        for col in df.columns:\n            col_type = df[col].dtypes\n            if col_type in numerics:\n                c_min = df[col].min()\n                c_max = df[col].max()\n                if str(col_type)[:3] == 'int':\n                    if c_min &gt; np.iinfo(np.int8).min and c_max &lt; np.iinfo(np.int8).max:\n                        df[col] = df[col].astype(np.int8)\n                    elif c_min &gt; np.iinfo(np.int16).min and c_max &lt; np.iinfo(np.int16).max:\n                        df[col] = df[col].astype(np.int16)\n                    elif c_min &gt; np.iinfo(np.int32).min and c_max &lt; np.iinfo(np.int32).max:\n                        df[col] = df[col].astype(np.int32)\n                    elif c_min &gt; np.iinfo(np.int64).min and c_max &lt; np.iinfo(np.int64).max:\n                        df[col] = df[col].astype(np.int64)  \n                else:\n                    if c_min &gt; np.finfo(np.float16).min and c_max &lt; np.finfo(np.float16).max:\n                        df[col] = df[col].astype(np.float16)\n                    elif c_min &gt; np.finfo(np.float32).min and c_max &lt; np.finfo(np.float32).max:\n                        df[col] = df[col].astype(np.float32)\n                    else:\n                        df[col] = df[col].astype(np.float64)    \n        end_mem = df.memory_usage().sum() / 1024**2\n        if verbose: print('Mem. usage decreased to {:5.2f} Mb ({:.1f}% reduction)'.format(end_mem, 100 * (start_mem - end_mem) / start_mem))\n        return df",
      "votes": 4,
      "replies": [
        {
          "id": 468080,
          "postDate": "2019-02-08T09:00:26.180Z",
          "content": "<p>Hey, Thanks for your help, I'm already using this function.</p>",
          "rawMarkdown": "Hey, Thanks for your help, I'm already using this function."
        },
        {
          "id": 468119,
          "postDate": "2019-02-08T10:29:58.233Z",
          "content": "<p>Do you use gc?</p>\n\n<p>import gc</p>\n\n<p>del train\ngc.collect()</p>",
          "rawMarkdown": "Do you use gc?\n\nimport gc\n\ndel train\ngc.collect()"
        },
        {
          "id": 468154,
          "postDate": "2019-02-08T11:35:32.963Z",
          "content": "<p>Here it is the kernel using that piece of code (at least here I found it): <a href=\"https://www.kaggle.com/mfjwr1/simple-lightgbm-without-blending\">https://www.kaggle.com/mfjwr1/simple-lightgbm-without-blending</a></p>",
          "rawMarkdown": "Here it is the kernel using that piece of code (at least here I found it): https://www.kaggle.com/mfjwr1/simple-lightgbm-without-blending"
        },
        {
          "id": 468270,
          "postDate": "2019-02-08T15:50:59.120Z",
          "content": "<p>yup! I do use gc</p>",
          "rawMarkdown": "yup! I do use gc"
        },
        {
          "id": 843685,
          "postDate": "2020-05-12T07:48:08.997Z",
          "content": "<p>hi <a href=\"/pranavmahajan725\">@pranavmahajan725</a> &amp; <a href=\"/gpreda\">@gpreda</a>, even after using that the problem persists. Even after the garbage collection... Anything else you'd like to add up on that? Maybe calling the function several times in the script??</p>",
          "rawMarkdown": "hi @pranavmahajan725 &amp; @gpreda, even after using that the problem persists. Even after the garbage collection... Anything else you'd like to add up on that? Maybe calling the function several times in the script??\n"
        }
      ]
    },
    {
      "id": 468548,
      "postDate": "2019-02-09T05:57:33.933Z",
      "content": "<p>Re-installation helped me .\nPlease try if still facing the same issue.</p>",
      "rawMarkdown": "Re-installation helped me .\nPlease try if still facing the same issue.",
      "votes": 1
    },
    {
      "id": 467583,
      "postDate": "2019-02-07T11:28:57.223Z",
      "content": "<p>@IbtesamAhmed </p>\n\n<ol>\n<li>If possible use <code>numpy</code> arrays rather than a list everywhere in your code. </li>\n<li>Use datable from h2o.ai as dataframe, it has better way of storing larger datasets in memory as compared to pandas. This has been already described here <a href=\"https://www.kaggle.com/c/microsoft-malware-prediction/discussion/75478\">https://www.kaggle.com/c/microsoft-malware-prediction/discussion/75478</a> FYI you have to connect your kernel to network by default it is not connected, you should be able to install it using pre made wheel see full details here <a href=\"https://www.kaggle.com/tunguz/eda-with-python-datatable\">https://www.kaggle.com/tunguz/eda-with-python-datatable</a></li>\n</ol>\n\n<p>Hopefully this will help. Happy Kaggling. :)</p>",
      "rawMarkdown": "@IbtesamAhmed \n\n 1. If possible use `numpy` arrays rather than a list everywhere in your code. \n 2. Use datable from h2o.ai as dataframe, it has better way of storing larger datasets in memory as compared to pandas. This has been already described here https://www.kaggle.com/c/microsoft-malware-prediction/discussion/75478 FYI you have to connect your kernel to network by default it is not connected, you should be able to install it using pre made wheel see full details here https://www.kaggle.com/tunguz/eda-with-python-datatable\n\nHopefully this will help. Happy Kaggling. :)",
      "votes": 1,
      "replies": [
        {
          "id": 467608,
          "postDate": "2019-02-07T12:16:13.370Z",
          "content": "<p>This is helpful. Thanks!</p>",
          "rawMarkdown": "This is helpful. Thanks!"
        }
      ]
    },
    {
      "id": 467579,
      "postDate": "2019-02-07T11:09:09.467Z",
      "content": "<p>use Dask it really helps in dealing with large data</p>",
      "rawMarkdown": "use Dask it really helps in dealing with large data",
      "votes": 1,
      "replies": [
        {
          "id": 467611,
          "postDate": "2019-02-07T12:17:40.733Z",
          "content": "<p>Thanks</p>",
          "rawMarkdown": "Thanks"
        }
      ]
    },
    {
      "id": 467073,
      "postDate": "2019-02-06T12:17:43.780Z",
      "content": "<p>Hi!\nI had problem with memory too. First I had 4 GB (WIN64) which was enough but very slow. If I used jupiter notebook and Spyder in the same time,  the memory error came. After I just use the Spyder IDE the memory error disappeared , but still very slow. After I bought another 4GB RAM and  my memory problem solved. \nGeri</p>",
      "rawMarkdown": "Hi!\nI had problem with memory too. First I had 4 GB (WIN64) which was enough but very slow. If I used jupiter notebook and Spyder in the same time,  the memory error came. After I just use the Spyder IDE the memory error disappeared , but still very slow. After I bought another 4GB RAM and  my memory problem solved. \nGeri",
      "votes": 1,
      "replies": [
        {
          "id": 467101,
          "postDate": "2019-02-06T13:09:51.993Z",
          "content": "<p>Hey,\nI'm using the kaggle kernel environment. I'm not running it locally</p>",
          "rawMarkdown": "Hey,\nI'm using the kaggle kernel environment. I'm not running it locally"
        }
      ]
    },
    {
      "id": 466775,
      "postDate": "2019-02-05T22:56:56.913Z",
      "content": "<p>I usually split the transaction and new merchant data frame based on train transactions and test transactions.  Then, I run the feature engineering on each split.</p>",
      "rawMarkdown": "I usually split the transaction and new merchant data frame based on train transactions and test transactions.  Then, I run the feature engineering on each split.",
      "votes": 1
    },
    {
      "id": 469187,
      "postDate": "2019-02-10T17:05:26.393Z",
      "content": "<p>Use pyspark</p>",
      "rawMarkdown": "Use pyspark",
      "votes": -2
    },
    {
      "id": 1385605,
      "postDate": "2021-07-12T20:37:46.003Z",
      "content": "<p>Use Modin + Dask, will really going to help with the error.<br>\nAnd, the best part is, It's very much similar to what we do as -<br>\nimport pandas as pd</p>\n<p>Instead we need to do-<br>\nimport modin.pandas as pd </p>",
      "rawMarkdown": "Use Modin + Dask, will really going to help with the error.\nAnd, the best part is, It's very much similar to what we do as -\nimport pandas as pd\n\nInstead we need to do-\nimport modin.pandas as pd "
    },
    {
      "id": 962303,
      "postDate": "2020-08-08T03:13:09.063Z",
      "content": "<p>I tried almost all the methods mentioned below but its not working .</p>\n\n<p>Is it specific for this competition only</p>",
      "rawMarkdown": "I tried almost all the methods mentioned below but its not working .\n\nIs it specific for this competition only"
    },
    {
      "id": 466332,
      "postDate": "2019-02-05T06:24:53.013Z",
      "content": "<p>If using windows platform, the problem could be solved by virtual memory, but one disadvantage is quite slow speed.</p>",
      "rawMarkdown": "If using windows platform, the problem could be solved by virtual memory, but one disadvantage is quite slow speed."
    },
    {
      "id": 466479,
      "postDate": "2019-02-05T13:13:33.880Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 783090,
      "author_name": "Pythonian",
      "author_url": "",
      "post_date": "2020-03-23T01:41:12.247000",
      "content": "<p>I said to use pyspark because you can store your features in their database instead of locally, you can even run your ml calculations in their cloud system. So I don't understand why you down voted me.</p>",
      "votes": 5,
      "replies": []
    },
    {
      "id": 468661,
      "author_name": "Kevin Jilg",
      "author_url": "",
      "post_date": "2019-02-09T12:03:05.533000",
      "content": "<p>Hi, if you are using pandas.read_csv function, set the parameters iterator=True and chunksize to a reasonable value to iterate lazily instead of reading the whole file into memory.</p>\n\n<p>Example:</p>\n\n<pre><code>train = pd.read_csv('train.csv', iterator=True, chunksize=100_000, dtype={'x': np.int16, 'y': np.float64})\nX_train = pd.DataFrame()\ny_train = pd.Series()\n\nfor df in train:\n    X_train = X_train.append(your_feature_engineering_function(df))\n    y_train = y_train.append(pd.Series(df['y'].values[-1]))\n    # this does feature engineering per chunk\n</code></pre>\n\n<p>Hope this is helpful.</p>",
      "votes": 7,
      "replies": []
    },
    {
      "id": 468017,
      "author_name": "Pranav Mahajan",
      "author_url": "",
      "post_date": "2019-02-08T06:24:30.373000",
      "content": "<p>I found this piece of code in one of the kernels (I don't remember, sorry) but it really helps get rid of memory errors by choosing the right data type I think.\nYou can just call this, like <code>new_df= reduce_mem_usage(new_df)</code> etc.</p>\n\n<pre><code>def reduce_mem_usage(df, verbose=True):\n    numerics = ['int16', 'int32', 'int64', 'float16', 'float32', 'float64']\n    start_mem = df.memory_usage().sum() / 1024**2    \n    for col in df.columns:\n        col_type = df[col].dtypes\n        if col_type in numerics:\n            c_min = df[col].min()\n            c_max = df[col].max()\n            if str(col_type)[:3] == 'int':\n                if c_min &gt; np.iinfo(np.int8).min and c_max &lt; np.iinfo(np.int8).max:\n                    df[col] = df[col].astype(np.int8)\n                elif c_min &gt; np.iinfo(np.int16).min and c_max &lt; np.iinfo(np.int16).max:\n                    df[col] = df[col].astype(np.int16)\n                elif c_min &gt; np.iinfo(np.int32).min and c_max &lt; np.iinfo(np.int32).max:\n                    df[col] = df[col].astype(np.int32)\n                elif c_min &gt; np.iinfo(np.int64).min and c_max &lt; np.iinfo(np.int64).max:\n                    df[col] = df[col].astype(np.int64)  \n            else:\n                if c_min &gt; np.finfo(np.float16).min and c_max &lt; np.finfo(np.float16).max:\n                    df[col] = df[col].astype(np.float16)\n                elif c_min &gt; np.finfo(np.float32).min and c_max &lt; np.finfo(np.float32).max:\n                    df[col] = df[col].astype(np.float32)\n                else:\n                    df[col] = df[col].astype(np.float64)    \n    end_mem = df.memory_usage().sum() / 1024**2\n    if verbose: print('Mem. usage decreased to {:5.2f} Mb ({:.1f}% reduction)'.format(end_mem, 100 * (start_mem - end_mem) / start_mem))\n    return df\n</code></pre>",
      "votes": 4,
      "replies": [
        {
          "id": 468080,
          "author_name": "Ibtesam Ahmed",
          "author_url": "",
          "post_date": "2019-02-08T09:00:26.180000",
          "content": "<p>Hey, Thanks for your help, I'm already using this function.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 468119,
          "author_name": "Kemal Salihçavuşoğlu",
          "author_url": "",
          "post_date": "2019-02-08T10:29:58.233000",
          "content": "<p>Do you use gc?</p>\n\n<p>import gc</p>\n\n<p>del train\ngc.collect()</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 468154,
          "author_name": "Gabriel Preda",
          "author_url": "",
          "post_date": "2019-02-08T11:35:32.963000",
          "content": "<p>Here it is the kernel using that piece of code (at least here I found it): <a href=\"https://www.kaggle.com/mfjwr1/simple-lightgbm-without-blending\">https://www.kaggle.com/mfjwr1/simple-lightgbm-without-blending</a></p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 468270,
          "author_name": "Ibtesam Ahmed",
          "author_url": "",
          "post_date": "2019-02-08T15:50:59.120000",
          "content": "<p>yup! I do use gc</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 843685,
          "author_name": "Divyansh Agrawal",
          "author_url": "",
          "post_date": "2020-05-12T07:48:08.997000",
          "content": "<p>hi <a href=\"/pranavmahajan725\">@pranavmahajan725</a> &amp; <a href=\"/gpreda\">@gpreda</a>, even after using that the problem persists. Even after the garbage collection... Anything else you'd like to add up on that? Maybe calling the function several times in the script??</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 468548,
      "author_name": "Prachi",
      "author_url": "",
      "post_date": "2019-02-09T05:57:33.933000",
      "content": "<p>Re-installation helped me .\nPlease try if still facing the same issue.</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 467583,
      "author_name": "cyberia",
      "author_url": "",
      "post_date": "2019-02-07T11:28:57.223000",
      "content": "<p>@IbtesamAhmed </p>\n\n<ol>\n<li>If possible use <code>numpy</code> arrays rather than a list everywhere in your code. </li>\n<li>Use datable from h2o.ai as dataframe, it has better way of storing larger datasets in memory as compared to pandas. This has been already described here <a href=\"https://www.kaggle.com/c/microsoft-malware-prediction/discussion/75478\">https://www.kaggle.com/c/microsoft-malware-prediction/discussion/75478</a> FYI you have to connect your kernel to network by default it is not connected, you should be able to install it using pre made wheel see full details here <a href=\"https://www.kaggle.com/tunguz/eda-with-python-datatable\">https://www.kaggle.com/tunguz/eda-with-python-datatable</a></li>\n</ol>\n\n<p>Hopefully this will help. Happy Kaggling. :)</p>",
      "votes": 1,
      "replies": [
        {
          "id": 467608,
          "author_name": "Ibtesam Ahmed",
          "author_url": "",
          "post_date": "2019-02-07T12:16:13.370000",
          "content": "<p>This is helpful. Thanks!</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 467579,
      "author_name": "ayush",
      "author_url": "",
      "post_date": "2019-02-07T11:09:09.467000",
      "content": "<p>use Dask it really helps in dealing with large data</p>",
      "votes": 1,
      "replies": [
        {
          "id": 467611,
          "author_name": "Ibtesam Ahmed",
          "author_url": "",
          "post_date": "2019-02-07T12:17:40.733000",
          "content": "<p>Thanks</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 467073,
      "author_name": "Gergely Iski",
      "author_url": "",
      "post_date": "2019-02-06T12:17:43.780000",
      "content": "<p>Hi!\nI had problem with memory too. First I had 4 GB (WIN64) which was enough but very slow. If I used jupiter notebook and Spyder in the same time,  the memory error came. After I just use the Spyder IDE the memory error disappeared , but still very slow. After I bought another 4GB RAM and  my memory problem solved. \nGeri</p>",
      "votes": 1,
      "replies": [
        {
          "id": 467101,
          "author_name": "Ibtesam Ahmed",
          "author_url": "",
          "post_date": "2019-02-06T13:09:51.993000",
          "content": "<p>Hey,\nI'm using the kaggle kernel environment. I'm not running it locally</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 466775,
      "author_name": "Kyle Peters",
      "author_url": "",
      "post_date": "2019-02-05T22:56:56.913000",
      "content": "<p>I usually split the transaction and new merchant data frame based on train transactions and test transactions.  Then, I run the feature engineering on each split.</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 469187,
      "author_name": "Pythonian",
      "author_url": "",
      "post_date": "2019-02-10T17:05:26.393000",
      "content": "<p>Use pyspark</p>",
      "votes": -2,
      "replies": []
    },
    {
      "id": 1385605,
      "author_name": "Navneet",
      "author_url": "",
      "post_date": "2021-07-12T20:37:46.003000",
      "content": "<p>Use Modin + Dask, will really going to help with the error.<br>\nAnd, the best part is, It's very much similar to what we do as -<br>\nimport pandas as pd</p>\n<p>Instead we need to do-<br>\nimport modin.pandas as pd </p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 962303,
      "author_name": "iffy_",
      "author_url": "",
      "post_date": "2020-08-08T03:13:09.063000",
      "content": "<p>I tried almost all the methods mentioned below but its not working .</p>\n\n<p>Is it specific for this competition only</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 466332,
      "author_name": "Eric Wu",
      "author_url": "",
      "post_date": "2019-02-05T06:24:53.013000",
      "content": "<p>If using windows platform, the problem could be solved by virtual memory, but one disadvantage is quite slow speed.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 466479,
      "author_name": "",
      "author_url": "",
      "post_date": "2019-02-05T13:13:33.880000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "783090": "I said to use pyspark because you can store your features in their database instead of locally, you can even run your ml calculations in their cloud system. So I don't understand why you down voted me.",
    "466314": "Due to the length of the code or extra features added during feature engineering , my kernel is restarting again and again(all the 14GB RAM space gets used up).I've seen people have more features than mine and their kernels seems to run just fine.\n\nAny suggestions to fix this would help!\n\nThanks",
    "468661": "Hi, if you are using pandas.read_csv function, set the parameters iterator=True and chunksize to a reasonable value to iterate lazily instead of reading the whole file into memory.\n\nExample:\n\n    train = pd.read_csv('train.csv', iterator=True, chunksize=100_000, dtype={'x': np.int16, 'y': np.float64})\n    X_train = pd.DataFrame()\n    y_train = pd.Series()\n\n    for df in train:\n        X_train = X_train.append(your_feature_engineering_function(df))\n        y_train = y_train.append(pd.Series(df['y'].values[-1]))\n        # this does feature engineering per chunk\n\nHope this is helpful.",
    "468017": "I found this piece of code in one of the kernels (I don't remember, sorry) but it really helps get rid of memory errors by choosing the right data type I think.\nYou can just call this, like `new_df= reduce_mem_usage(new_df)` etc.\n\n    def reduce_mem_usage(df, verbose=True):\n        numerics = ['int16', 'int32', 'int64', 'float16', 'float32', 'float64']\n        start_mem = df.memory_usage().sum() / 1024**2    \n        for col in df.columns:\n            col_type = df[col].dtypes\n            if col_type in numerics:\n                c_min = df[col].min()\n                c_max = df[col].max()\n                if str(col_type)[:3] == 'int':\n                    if c_min &gt; np.iinfo(np.int8).min and c_max &lt; np.iinfo(np.int8).max:\n                        df[col] = df[col].astype(np.int8)\n                    elif c_min &gt; np.iinfo(np.int16).min and c_max &lt; np.iinfo(np.int16).max:\n                        df[col] = df[col].astype(np.int16)\n                    elif c_min &gt; np.iinfo(np.int32).min and c_max &lt; np.iinfo(np.int32).max:\n                        df[col] = df[col].astype(np.int32)\n                    elif c_min &gt; np.iinfo(np.int64).min and c_max &lt; np.iinfo(np.int64).max:\n                        df[col] = df[col].astype(np.int64)  \n                else:\n                    if c_min &gt; np.finfo(np.float16).min and c_max &lt; np.finfo(np.float16).max:\n                        df[col] = df[col].astype(np.float16)\n                    elif c_min &gt; np.finfo(np.float32).min and c_max &lt; np.finfo(np.float32).max:\n                        df[col] = df[col].astype(np.float32)\n                    else:\n                        df[col] = df[col].astype(np.float64)    \n        end_mem = df.memory_usage().sum() / 1024**2\n        if verbose: print('Mem. usage decreased to {:5.2f} Mb ({:.1f}% reduction)'.format(end_mem, 100 * (start_mem - end_mem) / start_mem))\n        return df",
    "468548": "Re-installation helped me .\nPlease try if still facing the same issue.",
    "467583": "@IbtesamAhmed \n\n 1. If possible use `numpy` arrays rather than a list everywhere in your code. \n 2. Use datable from h2o.ai as dataframe, it has better way of storing larger datasets in memory as compared to pandas. This has been already described here https://www.kaggle.com/c/microsoft-malware-prediction/discussion/75478 FYI you have to connect your kernel to network by default it is not connected, you should be able to install it using pre made wheel see full details here https://www.kaggle.com/tunguz/eda-with-python-datatable\n\nHopefully this will help. Happy Kaggling. :)",
    "467579": "use Dask it really helps in dealing with large data",
    "467073": "Hi!\nI had problem with memory too. First I had 4 GB (WIN64) which was enough but very slow. If I used jupiter notebook and Spyder in the same time,  the memory error came. After I just use the Spyder IDE the memory error disappeared , but still very slow. After I bought another 4GB RAM and  my memory problem solved. \nGeri",
    "466775": "I usually split the transaction and new merchant data frame based on train transactions and test transactions.  Then, I run the feature engineering on each split.",
    "469187": "Use pyspark",
    "1385605": "Use Modin + Dask, will really going to help with the error.\nAnd, the best part is, It's very much similar to what we do as -\nimport pandas as pd\n\nInstead we need to do-\nimport modin.pandas as pd ",
    "962303": "I tried almost all the methods mentioned below but its not working .\n\nIs it specific for this competition only",
    "466332": "If using windows platform, the problem could be solved by virtual memory, but one disadvantage is quite slow speed.",
    "466479": ""
  }
}