{
  "id": 404814,
  "title": "Does anything wrong with XGBoost?👀",
  "url": "/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/404814",
  "author_name": "RogerOcean",
  "post_date": "2023-04-25T03:17:41.671000",
  "votes": 0,
  "comment_count": 0,
  "views": 0,
  "content": "<p>Hi fellow kagglers:<br>\nI have trained a xgb model locally and when I want to move it to kaggle environment, I fail to do that and meet many weird things, I'm wondering if anyone meet the same situations with me? <br>\nthe following is the detail:</p>\n<h2>use xgb's external_memory</h2>\n<p>I learned a lot from <a href=\"https://www.kaggle.com/code/xzj19013742/simple-eda-on-time-for-targets\" target=\"_blank\">Simple EDA on Time for targets</a> and my first version of code is quiet similar to that(main difference is I use xgb except lgbm).<br>\nI notice writer sample 10% of data to train (otherwise code will exceed memory limits).So my first thoughts is use external memory to avoid that, here is relevant code</p>\n<pre><code>skf = GroupKFold(n_kfolds)\n fold, (train_idx, valid_idx)  tqdm((skf.split(.....)):\n\n   train_data_parts = train_data.iloc[train_idx, :]\n   valid_data_parts = train_data.iloc[valid_idx, :]\n   \n   dump_svmlight_file(X=train_data_parts[feas_all]\n                      , y=train_data_parts[y_label]\n                      , f=)\n    train_data_parts\n   \n   \n   dtrain = xgb.DMatrix(join(path_save, )\n                              , feature_names=feas_all)\n\n   dvalid = xgb.DMatrix(valid_data_parts[feas_all].values\n                    , label=valid_data_parts[y_label]\n                    , feature_names=feas_all)\n</code></pre>\n<p>And what I get when I use \"save version\" func(after I click the button, kaggle will automatically run the code) is the code stop when it finish     <code>dump_svmlight_file</code> func at first fold and don't run the following code, and nothing else happen, it just stop running and generate a new version of code.</p>\n<h2>use pretrained xgbmodel or train an online xgbmodel</h2>\n<p>Later, I try to train my xgbmodel locally and upload it to kaggle envirnment (<code>dump_svmlight_file</code> cost nearly one hour if I use all data from defog+tdcafog, it's not a time saving solution so I didn't spend more time on it). But I get \"<strong>Notebook Threw Exception</strong>\" instead.<br>\nI swear I read most of revelent discussions like: <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/402373\" target=\"_blank\">[solved] Notebook threw Exception error- I've tried fixing the submission loop!</a>, <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401803\" target=\"_blank\">Gait Prediction - Notebook Threw Exception \"Please Help\"</a>, <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401582\" target=\"_blank\">Need Help - Submission Scoring Error??</a>, <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401199\" target=\"_blank\">I need help with the error: Notebook Threw Exception</a>, <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401745\" target=\"_blank\">How I (usually) solve my \"submission score error\"</a>, <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/394092\" target=\"_blank\">is there any problem on my submission file?</a>, <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/397516\" target=\"_blank\">Notebook runs successfully, but there is no score</a> etc. I avoid all the problem mentioned in discussions but still <strong>code can't run successfully until I change xgb to lgbm and finally I can get score</strong>!<br>\nThe same thing happens when I train an online xgbmodel (after sampling 5% data to avoid memory explosion), the code doesn't work until I use lgbm model, and I don't change ohter part of code</p>\n<h2>conclusion</h2>\n<p>I really spend several day on this problem and I understand in <a href=\"https://www.kaggle.com/discussions/product-feedback/121112\" target=\"_blank\">What is: \"Notebook Threw Exception\"</a>, kaggle team said: \"Your notebook is rerun with the private dataset. You don't get to see the log from that run because it could be used to exfiltrate the private host data. This error means your notebook threw an exception while processing the private data, even if it doesn't encounter such an error in the pubic data.\"<br>\nbut I really spend a lot of time to guess what's wrong with my code.😅 Or is it a common thing everyone know besides me? maybe it's why I don't see code using xgboost to train model in \"Code\"<br>\nDoes anyone has the same confusion?👀</p>",
  "messages": [
    {
      "id": 2234230,
      "postDate": "2023-04-25T03:17:41.673Z",
      "content": "<p>Hi fellow kagglers:<br>\nI have trained a xgb model locally and when I want to move it to kaggle environment, I fail to do that and meet many weird things, I'm wondering if anyone meet the same situations with me? <br>\nthe following is the detail:</p>\n<h2>use xgb's external_memory</h2>\n<p>I learned a lot from <a href=\"https://www.kaggle.com/code/xzj19013742/simple-eda-on-time-for-targets\" target=\"_blank\">Simple EDA on Time for targets</a> and my first version of code is quiet similar to that(main difference is I use xgb except lgbm).<br>\nI notice writer sample 10% of data to train (otherwise code will exceed memory limits).So my first thoughts is use external memory to avoid that, here is relevant code</p>\n<pre><code>skf = GroupKFold(n_kfolds)\n fold, (train_idx, valid_idx)  tqdm((skf.split(.....)):\n\n   train_data_parts = train_data.iloc[train_idx, :]\n   valid_data_parts = train_data.iloc[valid_idx, :]\n   \n   dump_svmlight_file(X=train_data_parts[feas_all]\n                      , y=train_data_parts[y_label]\n                      , f=)\n    train_data_parts\n   \n   \n   dtrain = xgb.DMatrix(join(path_save, )\n                              , feature_names=feas_all)\n\n   dvalid = xgb.DMatrix(valid_data_parts[feas_all].values\n                    , label=valid_data_parts[y_label]\n                    , feature_names=feas_all)\n</code></pre>\n<p>And what I get when I use \"save version\" func(after I click the button, kaggle will automatically run the code) is the code stop when it finish     <code>dump_svmlight_file</code> func at first fold and don't run the following code, and nothing else happen, it just stop running and generate a new version of code.</p>\n<h2>use pretrained xgbmodel or train an online xgbmodel</h2>\n<p>Later, I try to train my xgbmodel locally and upload it to kaggle envirnment (<code>dump_svmlight_file</code> cost nearly one hour if I use all data from defog+tdcafog, it's not a time saving solution so I didn't spend more time on it). But I get \"<strong>Notebook Threw Exception</strong>\" instead.<br>\nI swear I read most of revelent discussions like: <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/402373\" target=\"_blank\">[solved] Notebook threw Exception error- I've tried fixing the submission loop!</a>, <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401803\" target=\"_blank\">Gait Prediction - Notebook Threw Exception \"Please Help\"</a>, <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401582\" target=\"_blank\">Need Help - Submission Scoring Error??</a>, <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401199\" target=\"_blank\">I need help with the error: Notebook Threw Exception</a>, <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401745\" target=\"_blank\">How I (usually) solve my \"submission score error\"</a>, <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/394092\" target=\"_blank\">is there any problem on my submission file?</a>, <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/397516\" target=\"_blank\">Notebook runs successfully, but there is no score</a> etc. I avoid all the problem mentioned in discussions but still <strong>code can't run successfully until I change xgb to lgbm and finally I can get score</strong>!<br>\nThe same thing happens when I train an online xgbmodel (after sampling 5% data to avoid memory explosion), the code doesn't work until I use lgbm model, and I don't change ohter part of code</p>\n<h2>conclusion</h2>\n<p>I really spend several day on this problem and I understand in <a href=\"https://www.kaggle.com/discussions/product-feedback/121112\" target=\"_blank\">What is: \"Notebook Threw Exception\"</a>, kaggle team said: \"Your notebook is rerun with the private dataset. You don't get to see the log from that run because it could be used to exfiltrate the private host data. This error means your notebook threw an exception while processing the private data, even if it doesn't encounter such an error in the pubic data.\"<br>\nbut I really spend a lot of time to guess what's wrong with my code.😅 Or is it a common thing everyone know besides me? maybe it's why I don't see code using xgboost to train model in \"Code\"<br>\nDoes anyone has the same confusion?👀</p>",
      "rawMarkdown": "\nHi fellow kagglers:\n\nI have trained a xgb model locally and when I want to move it to kaggle environment, I fail to do that and meet many weird things, I'm wondering if anyone meet the same situations with me? \n\nthe following is the detail:\n\n## use xgb's external_memory \n\nI learned a lot from [Simple EDA on Time for targets](https://www.kaggle.com/code/xzj19013742/simple-eda-on-time-for-targets) and my first version of code is quiet similar to that(main difference is I use xgb except lgbm).\n\nI notice writer sample 10% of data to train (otherwise code will exceed memory limits).So my first thoughts is use external memory to avoid that, here is relevant code\n\n```python\n\nskf = GroupKFold(n_kfolds)\n\nfor fold, (train_idx, valid_idx) in tqdm(enumerate(skf.split(.....)):\n    \n    train_data_parts = train_data.iloc[train_idx, :]\n    valid_data_parts = train_data.iloc[valid_idx, :]\n\n    # from sklearn.datasets import dump_svmlight_file\n    dump_svmlight_file(X=train_data_parts[feas_all]\n                       , y=train_data_parts[y_label]\n                       , f=f'{FILESAVE_BASE}_train_data_kfold{fold}.txt.train')\n    del train_data_parts\n\n    # svmlight_file can't save cols'name so we need use `feature_names` to tell xgb the feature name\n    # svmlight_file can't save np.nan and we need to fillna at first, I have done before\n    dtrain = xgb.DMatrix(join(path_save, f'{FILESAVE_BASE}_train_data_kfold{fold}.txt.train#train_cache.cache')\n                               , feature_names=feas_all)\n    \n    dvalid = xgb.DMatrix(valid_data_parts[feas_all].values\n                     , label=valid_data_parts[y_label]\n                     , feature_names=feas_all)\n\n```\n\nAnd what I get when I use \"save version\" func(after I click the button, kaggle will automatically run the code) is the code stop when it finish     `dump_svmlight_file` func at first fold and don't run the following code, and nothing else happen, it just stop running and generate a new version of code.\n\n\n## use pretrained xgbmodel or train an online xgbmodel\n\nLater, I try to train my xgbmodel locally and upload it to kaggle envirnment (`dump_svmlight_file` cost nearly one hour if I use all data from defog+tdcafog, it's not a time saving solution so I didn't spend more time on it). But I get \"**Notebook Threw Exception**\" instead.\n\nI swear I read most of revelent discussions like: [[solved] Notebook threw Exception error- I've tried fixing the submission loop!](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/402373), [Gait Prediction - Notebook Threw Exception \"Please Help\"](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401803), [Need Help - Submission Scoring Error??](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401582), [I need help with the error: Notebook Threw Exception](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401199), [How I (usually) solve my \"submission score error\"](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401745), [is there any problem on my submission file?](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/394092), [Notebook runs successfully, but there is no score](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/397516) etc. I avoid all the problem mentioned in discussions but still **code can't run successfully until I change xgb to lgbm and finally I can get score**!\n\nThe same thing happens when I train an online xgbmodel (after sampling 5% data to avoid memory explosion), the code doesn't work until I use lgbm model, and I don't change ohter part of code\n\n## conclusion\n\nI really spend several day on this problem and I understand in [What is: \"Notebook Threw Exception\"](https://www.kaggle.com/discussions/product-feedback/121112), kaggle team said: \"Your notebook is rerun with the private dataset. You don't get to see the log from that run because it could be used to exfiltrate the private host data. This error means your notebook threw an exception while processing the private data, even if it doesn't encounter such an error in the pubic data.\"\n\nbut I really spend a lot of time to guess what's wrong with my code.😅 Or is it a common thing everyone know besides me? maybe it's why I don't see code using xgboost to train model in \"Code\"\n\nDoes anyone has the same confusion?👀\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "2234230": "\nHi fellow kagglers:\n\nI have trained a xgb model locally and when I want to move it to kaggle environment, I fail to do that and meet many weird things, I'm wondering if anyone meet the same situations with me? \n\nthe following is the detail:\n\n## use xgb's external_memory \n\nI learned a lot from [Simple EDA on Time for targets](https://www.kaggle.com/code/xzj19013742/simple-eda-on-time-for-targets) and my first version of code is quiet similar to that(main difference is I use xgb except lgbm).\n\nI notice writer sample 10% of data to train (otherwise code will exceed memory limits).So my first thoughts is use external memory to avoid that, here is relevant code\n\n```python\n\nskf = GroupKFold(n_kfolds)\n\nfor fold, (train_idx, valid_idx) in tqdm(enumerate(skf.split(.....)):\n    \n    train_data_parts = train_data.iloc[train_idx, :]\n    valid_data_parts = train_data.iloc[valid_idx, :]\n\n    # from sklearn.datasets import dump_svmlight_file\n    dump_svmlight_file(X=train_data_parts[feas_all]\n                       , y=train_data_parts[y_label]\n                       , f=f'{FILESAVE_BASE}_train_data_kfold{fold}.txt.train')\n    del train_data_parts\n\n    # svmlight_file can't save cols'name so we need use `feature_names` to tell xgb the feature name\n    # svmlight_file can't save np.nan and we need to fillna at first, I have done before\n    dtrain = xgb.DMatrix(join(path_save, f'{FILESAVE_BASE}_train_data_kfold{fold}.txt.train#train_cache.cache')\n                               , feature_names=feas_all)\n    \n    dvalid = xgb.DMatrix(valid_data_parts[feas_all].values\n                     , label=valid_data_parts[y_label]\n                     , feature_names=feas_all)\n\n```\n\nAnd what I get when I use \"save version\" func(after I click the button, kaggle will automatically run the code) is the code stop when it finish     `dump_svmlight_file` func at first fold and don't run the following code, and nothing else happen, it just stop running and generate a new version of code.\n\n\n## use pretrained xgbmodel or train an online xgbmodel\n\nLater, I try to train my xgbmodel locally and upload it to kaggle envirnment (`dump_svmlight_file` cost nearly one hour if I use all data from defog+tdcafog, it's not a time saving solution so I didn't spend more time on it). But I get \"**Notebook Threw Exception**\" instead.\n\nI swear I read most of revelent discussions like: [[solved] Notebook threw Exception error- I've tried fixing the submission loop!](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/402373), [Gait Prediction - Notebook Threw Exception \"Please Help\"](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401803), [Need Help - Submission Scoring Error??](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401582), [I need help with the error: Notebook Threw Exception](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401199), [How I (usually) solve my \"submission score error\"](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/401745), [is there any problem on my submission file?](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/394092), [Notebook runs successfully, but there is no score](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/397516) etc. I avoid all the problem mentioned in discussions but still **code can't run successfully until I change xgb to lgbm and finally I can get score**!\n\nThe same thing happens when I train an online xgbmodel (after sampling 5% data to avoid memory explosion), the code doesn't work until I use lgbm model, and I don't change ohter part of code\n\n## conclusion\n\nI really spend several day on this problem and I understand in [What is: \"Notebook Threw Exception\"](https://www.kaggle.com/discussions/product-feedback/121112), kaggle team said: \"Your notebook is rerun with the private dataset. You don't get to see the log from that run because it could be used to exfiltrate the private host data. This error means your notebook threw an exception while processing the private data, even if it doesn't encounter such an error in the pubic data.\"\n\nbut I really spend a lot of time to guess what's wrong with my code.😅 Or is it a common thing everyone know besides me? maybe it's why I don't see code using xgboost to train model in \"Code\"\n\nDoes anyone has the same confusion?👀\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
  }
}