{
  "id": 403055,
  "title": "Model Inference Example and \"Guide\"",
  "url": "/competitions/predict-student-performance-from-game-play/discussion/403055",
  "author_name": "",
  "post_date": "2023-04-20T23:38:56.072373500Z",
  "votes": 1,
  "comment_count": 1,
  "views": 0,
  "content": "<p>Hey everybody,</p>\n<p>I was struggling with loading 18 models into a a competition notebook in order to get it to score the test competition data, so I figured I would post my model inference notebook <a href=\"https://www.kaggle.com/code/paulmerica/model-inference\" target=\"_blank\">here</a> . Hopefully this provides a good helping point for anyone else struggling with loading their models in after using<a href=\"https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396979\" target=\"_blank\"> Chris' 2 notebook method</a>  . Also if you are curious how I saved my models in the training environment, it is saved in the \"XGBoost Train\" section of Chris' baseline XGboost notebook <a href=\"https://www.kaggle.com/code/cdeotte/xgboost-baseline-0-680\" target=\"_blank\">here</a> . I just made the following change (added     clf.save_model(f'XGB_question{t}.xgb')   ) to his notebook in the #train model part: </p>\n<pre><code>    # TRAIN MODEL        \n    clf =  XGBClassifier(**xgb_params)\n    clf.fit(train_x[FEATURES].astype('float32'), train_y['correct'],\n            eval_set=[ (valid_x[FEATURES].astype('float32'), valid_y['correct']) ],\n            verbose=0)\n    print(f'{t}({clf.best_ntree_limit}), ',end='')\n    clf.save_model(f'XGB_question{t}.xgb')  \n</code></pre>\n<p>Hopefully this helps some of you get the infrastructure corrected so that you guys can train and upload your own models! I essentially just split Chris' notebook into two parts so we all have an example.<br>\n )</p>",
  "messages": [
    {
      "id": "2228922",
      "postDate": "04/20/2023 23:38:56",
      "content": "<p>Hey everybody,</p>\n<p>I was struggling with loading 18 models into a a competition notebook in order to get it to score the test competition data, so I figured I would post my model inference notebook <a href=\"https://www.kaggle.com/code/paulmerica/model-inference\" target=\"_blank\">here</a> . Hopefully this provides a good helping point for anyone else struggling with loading their models in after using<a href=\"https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396979\" target=\"_blank\"> Chris' 2 notebook method</a>  . Also if you are curious how I saved my models in the training environment, it is saved in the \"XGBoost Train\" section of Chris' baseline XGboost notebook <a href=\"https://www.kaggle.com/code/cdeotte/xgboost-baseline-0-680\" target=\"_blank\">here</a> . I just made the following change (added     clf.save_model(f'XGB_question{t}.xgb')   ) to his notebook in the #train model part: </p>\n<pre><code>    # TRAIN MODEL        \n    clf =  XGBClassifier(**xgb_params)\n    clf.fit(train_x[FEATURES].astype('float32'), train_y['correct'],\n            eval_set=[ (valid_x[FEATURES].astype('float32'), valid_y['correct']) ],\n            verbose=0)\n    print(f'{t}({clf.best_ntree_limit}), ',end='')\n    clf.save_model(f'XGB_question{t}.xgb')  \n</code></pre>\n<p>Hopefully this helps some of you get the infrastructure corrected so that you guys can train and upload your own models! I essentially just split Chris' notebook into two parts so we all have an example.<br>\n )</p>",
      "rawMarkdown": "Hey everybody,\n\nI was struggling with loading 18 models into a a competition notebook in order to get it to score the test competition data, so I figured I would post my model inference notebook [here](https://www.kaggle.com/code/paulmerica/model-inference) . Hopefully this provides a good helping point for anyone else struggling with loading their models in after using[ Chris' 2 notebook method](https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396979)  . Also if you are curious how I saved my models in the training environment, it is saved in the \"XGBoost Train\" section of Chris' baseline XGboost notebook [here](https://www.kaggle.com/code/cdeotte/xgboost-baseline-0-680) . I just made the following change (added     clf.save_model(f'XGB_question{t}.xgb')   ) to his notebook in the #train model part: \n\n\n        # TRAIN MODEL        \n        clf =  XGBClassifier(**xgb_params)\n        clf.fit(train_x[FEATURES].astype('float32'), train_y['correct'],\n                eval_set=[ (valid_x[FEATURES].astype('float32'), valid_y['correct']) ],\n                verbose=0)\n        print(f'{t}({clf.best_ntree_limit}), ',end='')\n        clf.save_model(f'XGB_question{t}.xgb')  \n\n\n\nHopefully this helps some of you get the infrastructure corrected so that you guys can train and upload your own models! I essentially just split Chris' notebook into two parts so we all have an example.\n )",
      "votes": null
    },
    {
      "id": "2241559",
      "postDate": "05/01/2023 15:42:30",
      "content": "<p>18 models is too much. </p>",
      "rawMarkdown": "18 models is too much.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2241559,
      "author_name": "littlstar123",
      "author_url": "",
      "post_date": "05/01/2023 15:42:30",
      "content": "<p>18 models is too much. </p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2228922": "Hey everybody,\n\nI was struggling with loading 18 models into a a competition notebook in order to get it to score the test competition data, so I figured I would post my model inference notebook [here](https://www.kaggle.com/code/paulmerica/model-inference) . Hopefully this provides a good helping point for anyone else struggling with loading their models in after using[ Chris' 2 notebook method](https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396979)  . Also if you are curious how I saved my models in the training environment, it is saved in the \"XGBoost Train\" section of Chris' baseline XGboost notebook [here](https://www.kaggle.com/code/cdeotte/xgboost-baseline-0-680) . I just made the following change (added     clf.save_model(f'XGB_question{t}.xgb')   ) to his notebook in the #train model part: \n\n\n        # TRAIN MODEL        \n        clf =  XGBClassifier(**xgb_params)\n        clf.fit(train_x[FEATURES].astype('float32'), train_y['correct'],\n                eval_set=[ (valid_x[FEATURES].astype('float32'), valid_y['correct']) ],\n                verbose=0)\n        print(f'{t}({clf.best_ntree_limit}), ',end='')\n        clf.save_model(f'XGB_question{t}.xgb')  \n\n\n\nHopefully this helps some of you get the infrastructure corrected so that you guys can train and upload your own models! I essentially just split Chris' notebook into two parts so we all have an example.\n )",
    "2241559": "18 models is too much."
  },
  "source": "meta"
}