{
  "id": 402178,
  "title": "Persisting saved models",
  "url": "/competitions/predict-student-performance-from-game-play/discussion/402178",
  "author_name": "",
  "post_date": "2023-04-17T08:26:47.218360Z",
  "votes": null,
  "comment_count": 1,
  "views": 0,
  "content": "<p>Several discussion topics (such as <a href=\"https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396979\" target=\"_blank\">https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396979</a>) talk about managing training and inference in separate notebooks. Is there a tutorial on how to do this? I understand how modeling pickling works in python generally. But Kaggle seems to have a peculiar setup. I am trying to understand how/where to save models from my training notebook so that I can load and use them from a separate inference notebook. </p>",
  "messages": [
    {
      "id": "2224347",
      "postDate": "04/17/2023 08:26:47",
      "content": "<p>Several discussion topics (such as <a href=\"https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396979\" target=\"_blank\">https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396979</a>) talk about managing training and inference in separate notebooks. Is there a tutorial on how to do this? I understand how modeling pickling works in python generally. But Kaggle seems to have a peculiar setup. I am trying to understand how/where to save models from my training notebook so that I can load and use them from a separate inference notebook. </p>",
      "rawMarkdown": "Several discussion topics (such as https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396979) talk about managing training and inference in separate notebooks. Is there a tutorial on how to do this? I understand how modeling pickling works in python generally. But Kaggle seems to have a peculiar setup. I am trying to understand how/where to save models from my training notebook so that I can load and use them from a separate inference notebook.",
      "votes": null
    },
    {
      "id": "2226583",
      "postDate": "04/19/2023 03:52:17",
      "content": "<p>I figured this out. Posting an answer here for others who might have the same question. </p>\n<p>1) In your training notebook, select Persistence File Only or Persistence File and Variable under notebook options<br>\n2) Once your training notebook is ready, select Save Version. Under Save Type, make sure you have Save and Run All (Commit) is selected. This will run the notebook and commit the results to a version.  <br>\n3) Create a new inference notebook. Under the input section of the inference notebook, clic on Add Data and select Your Notebooks. Your training notebook should appear here. Add the notebook by clicking the plus button (Also note that in order for this to work, your training code must save your model artifacts using pickle, joblib etc. If you training code didn't save the model artifacts, the training notebook will not appear on this list). <br>\n4) The artifacts created by your training notebook should now appear in a separate input folder for your inference notebook. </p>",
      "rawMarkdown": "I figured this out. Posting an answer here for others who might have the same question. \n\n1) In your training notebook, select Persistence File Only or Persistence File and Variable under notebook options\n2) Once your training notebook is ready, select Save Version. Under Save Type, make sure you have Save and Run All (Commit) is selected. This will run the notebook and commit the results to a version.  \n3) Create a new inference notebook. Under the input section of the inference notebook, clic on Add Data and select Your Notebooks. Your training notebook should appear here. Add the notebook by clicking the plus button (Also note that in order for this to work, your training code must save your model artifacts using pickle, joblib etc. If you training code didn't save the model artifacts, the training notebook will not appear on this list). \n4) The artifacts created by your training notebook should now appear in a separate input folder for your inference notebook.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2226583,
      "author_name": "spacehorse",
      "author_url": "",
      "post_date": "04/19/2023 03:52:17",
      "content": "<p>I figured this out. Posting an answer here for others who might have the same question. </p>\n<p>1) In your training notebook, select Persistence File Only or Persistence File and Variable under notebook options<br>\n2) Once your training notebook is ready, select Save Version. Under Save Type, make sure you have Save and Run All (Commit) is selected. This will run the notebook and commit the results to a version.  <br>\n3) Create a new inference notebook. Under the input section of the inference notebook, clic on Add Data and select Your Notebooks. Your training notebook should appear here. Add the notebook by clicking the plus button (Also note that in order for this to work, your training code must save your model artifacts using pickle, joblib etc. If you training code didn't save the model artifacts, the training notebook will not appear on this list). <br>\n4) The artifacts created by your training notebook should now appear in a separate input folder for your inference notebook. </p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2224347": "Several discussion topics (such as https://www.kaggle.com/competitions/predict-student-performance-from-game-play/discussion/396979) talk about managing training and inference in separate notebooks. Is there a tutorial on how to do this? I understand how modeling pickling works in python generally. But Kaggle seems to have a peculiar setup. I am trying to understand how/where to save models from my training notebook so that I can load and use them from a separate inference notebook.",
    "2226583": "I figured this out. Posting an answer here for others who might have the same question. \n\n1) In your training notebook, select Persistence File Only or Persistence File and Variable under notebook options\n2) Once your training notebook is ready, select Save Version. Under Save Type, make sure you have Save and Run All (Commit) is selected. This will run the notebook and commit the results to a version.  \n3) Create a new inference notebook. Under the input section of the inference notebook, clic on Add Data and select Your Notebooks. Your training notebook should appear here. Add the notebook by clicking the plus button (Also note that in order for this to work, your training code must save your model artifacts using pickle, joblib etc. If you training code didn't save the model artifacts, the training notebook will not appear on this list). \n4) The artifacts created by your training notebook should now appear in a separate input folder for your inference notebook."
  },
  "source": "meta"
}