{
  "id": 549767,
  "title": "unable to load lightgbm from txt file",
  "url": "/competitions/jane-street-real-time-market-data-forecasting/discussion/549767",
  "author_name": "",
  "post_date": "2024-12-03T21:03:43.052184700Z",
  "votes": -1,
  "comment_count": 1,
  "views": 0,
  "content": "<p>I saved my trained lgbm model as txt and uploaded it to Kaggle as model. <br>\nHowever, when I try and load it through Kaggle, the notebook always dies ( I tried many times). The same trick however works for Catboost. Does anybody have any suggestion?</p>\n<p>bst = lgb.Booster(model_file='/kaggle/input/gbm-v1/gbm.txt')</p>",
  "messages": [
    {
      "id": "3062722",
      "postDate": "12/03/2024 21:03:43",
      "content": "<p>I saved my trained lgbm model as txt and uploaded it to Kaggle as model. <br>\nHowever, when I try and load it through Kaggle, the notebook always dies ( I tried many times). The same trick however works for Catboost. Does anybody have any suggestion?</p>\n<p>bst = lgb.Booster(model_file='/kaggle/input/gbm-v1/gbm.txt')</p>",
      "rawMarkdown": "I saved my trained lgbm model as txt and uploaded it to Kaggle as model. \nHowever, when I try and load it through Kaggle, the notebook always dies ( I tried many times). The same trick however works for Catboost. Does anybody have any suggestion?\n\nbst = lgb.Booster(model_file='/kaggle/input/gbm-v1/gbm.txt')",
      "votes": null
    },
    {
      "id": "3062784",
      "postDate": "12/03/2024 22:44:33",
      "content": "<p>Try pickling instead :)</p>\n<pre><code> pickle  pckl\n\npckl.dump(your_model_as_variable, (, ))\nyour_model_freshly_loaded = pckl.load((, ))\n</code></pre>",
      "rawMarkdown": "Try pickling instead :)\n\n```python\nimport pickle as pckl\n\npckl.dump(your_model_as_variable, open(\"A_name.pckl\", \"wb\"))\nyour_model_freshly_loaded = pckl.load(open(\"A_name.pckl\", \"rb\"))\n```",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 3062784,
      "author_name": "forecastingvibes",
      "author_url": "",
      "post_date": "12/03/2024 22:44:33",
      "content": "<p>Try pickling instead :)</p>\n<pre><code> pickle  pckl\n\npckl.dump(your_model_as_variable, (, ))\nyour_model_freshly_loaded = pckl.load((, ))\n</code></pre>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "3062722": "I saved my trained lgbm model as txt and uploaded it to Kaggle as model. \nHowever, when I try and load it through Kaggle, the notebook always dies ( I tried many times). The same trick however works for Catboost. Does anybody have any suggestion?\n\nbst = lgb.Booster(model_file='/kaggle/input/gbm-v1/gbm.txt')",
    "3062784": "Try pickling instead :)\n\n```python\nimport pickle as pckl\n\npckl.dump(your_model_as_variable, open(\"A_name.pckl\", \"wb\"))\nyour_model_freshly_loaded = pckl.load(open(\"A_name.pckl\", \"rb\"))\n```"
  },
  "source": "meta"
}