{
  "id": 205432,
  "title": "[IMP]Do this before Submitting Your Inference Notebook to Overcome Submission Scoring Error !",
  "url": "/competitions/riiid-test-answer-prediction/discussion/205432",
  "author_name": "Athar Sayed",
  "post_date": "2020-12-20T06:44:22.124000",
  "votes": 2,
  "comment_count": 0,
  "views": 0,
  "content": "<p>Most of the points causing Submission Scoring Error are discussed <a href=\"https://www.kaggle.com/c/riiid-test-answer-prediction/discussion/192124\" target=\"_blank\">here </a> , However  I thought of reiterating over those points and remind participants of this topic . As it goes your submission or inference notebook should get run within 9 hours of run time . As pointed out by <a href=\"https://www.kaggle.com/sohier\" target=\"_blank\">@sohier</a> <a href=\"https://www.kaggle.com/c/riiid-test-answer-prediction/discussion/196210\" target=\"_blank\">here</a> , this runtime is obfuscated with <strong>Kernel rerun on test set time + Some Random Additional Time which never push the entire kernel rerun time beyond 9 hrs .</strong><br>\nI was recently adding some features which were improving my Local Validation score significantly , but I was getting lots of <strong>Submission Scoring Error</strong> , Now I thought of debugging this issue step by step rather than solely relying on my submissions.</p>\n<p>Earlier I adopted this framework of flow.<br>\n1) Add Features .<br>\n2) Build Model<br>\n3) Validate Cv Performance<br>\n4) Build Inference Kernel !</p>\n<p>However As far as this competition is concerned this is the most unreliable and lot of <code>Submission Scoring Error</code> Prone Framework !</p>\n<p>Even though I knew about Time Series Emulator Api built by tito , I never used it ! I recently looked at it <a href=\"https://www.kaggle.com/its7171/time-series-api-iter-test-emulator\" target=\"_blank\">here</a> , in that we have a code segment as follows </p>\n<pre><code>pbar = tqdm(total=2500000)\nprevious_test_df = None\nfor (current_test, current_prediction_df) in iter_test:\n    if previous_test_df is not None:\n        answers = eval(current_test[\"prior_group_answers_correct\"].iloc[0])\n        responses = eval(current_test[\"prior_group_responses\"].iloc[0])\n        previous_test_df['answered_correctly'] = answers\n        previous_test_df['user_answer'] = responses\n        # Write all your update dict code here \n        # your feature extraction and model training code here\n    previous_test_df = current_test.copy()\n    current_test = current_test[current_test.content_type_id == 0]\n    # your prediction code here\n    # Write all your Feature Extratcion using Dict Code Here , that is \n    # Code which  simply fetches user value from dict without updating\n    current_test['answered_correctly'] = model.predict(current_test[FEATS])\n    set_predict(current_test.loc[:,['row_id', 'answered_correctly']])\n    pbar.update(len(current_test))\n</code></pre>\n<p>[Note : Use Sample Size of 2.5 Million rows in that script only , otherwise you won't get a correct estimate of run time of your script ]<br>\nI noticed that my Feature generation code for the loop and prediction was showing more than 9 hours of estimated time . Moreover I got some error also related to LightGbm ! <strong>Also Note that none of this issues were visible while making Commit using env.predict method provided my RIIID Module , Hence I didn't noticed this</strong>. Now it became clear to me why Submission Error was coming in the first place. I will resolve this issues and make sure to make submission .</p>\n<p>TLDR: Commiting your Inference Script just on env.predict by RIIID Module  does not give you an indication whether your Inference Kernel will succeed on Private Test Set Re Run , Hence Don't rely on it . </p>\n<p>Hence for this competition a Workflow will be .<br>\n1) Add Features .<br>\n2) Train Model and Validate its performance.<br>\n3)<strong>[Very Important Step] Use Test Emulator Provided <a href=\"https://www.kaggle.com/its7171/time-series-api-iter-test-emulator\" target=\"_blank\">here</a> , to ensure that entire step for Feature Generation and Prediction , lies within 9 hours of Window  on 2.5 Million Rows .</strong><br>\n4) Once you are sure that your Script works fine , then only go for submission.<br>\n5) If your script is taking too much time to generate features consider dropping less important features .<br>\n6) Only Submit your inference kernel if your model along with Feature Generation is taking less than 9 hours on emulator .</p>\n<p>This competition is more about writing efficient code as much as it is about modelling ! If you face an error be patient debug it step by step rather than simply using brute force.</p>\n<p>I shared it so that anyone who is stuck on this issue can overcome it quickly and feel less frustruation 😀  , that comes on seeing <code>Submission Scoring Error</code>.</p>",
  "messages": [
    {
      "id": 1119539,
      "postDate": "2020-12-20T06:44:22.123Z",
      "content": "<p>Most of the points causing Submission Scoring Error are discussed <a href=\"https://www.kaggle.com/c/riiid-test-answer-prediction/discussion/192124\" target=\"_blank\">here </a> , However  I thought of reiterating over those points and remind participants of this topic . As it goes your submission or inference notebook should get run within 9 hours of run time . As pointed out by <a href=\"https://www.kaggle.com/sohier\" target=\"_blank\">@sohier</a> <a href=\"https://www.kaggle.com/c/riiid-test-answer-prediction/discussion/196210\" target=\"_blank\">here</a> , this runtime is obfuscated with <strong>Kernel rerun on test set time + Some Random Additional Time which never push the entire kernel rerun time beyond 9 hrs .</strong><br>\nI was recently adding some features which were improving my Local Validation score significantly , but I was getting lots of <strong>Submission Scoring Error</strong> , Now I thought of debugging this issue step by step rather than solely relying on my submissions.</p>\n<p>Earlier I adopted this framework of flow.<br>\n1) Add Features .<br>\n2) Build Model<br>\n3) Validate Cv Performance<br>\n4) Build Inference Kernel !</p>\n<p>However As far as this competition is concerned this is the most unreliable and lot of <code>Submission Scoring Error</code> Prone Framework !</p>\n<p>Even though I knew about Time Series Emulator Api built by tito , I never used it ! I recently looked at it <a href=\"https://www.kaggle.com/its7171/time-series-api-iter-test-emulator\" target=\"_blank\">here</a> , in that we have a code segment as follows </p>\n<pre><code>pbar = tqdm(total=2500000)\nprevious_test_df = None\nfor (current_test, current_prediction_df) in iter_test:\n    if previous_test_df is not None:\n        answers = eval(current_test[\"prior_group_answers_correct\"].iloc[0])\n        responses = eval(current_test[\"prior_group_responses\"].iloc[0])\n        previous_test_df['answered_correctly'] = answers\n        previous_test_df['user_answer'] = responses\n        # Write all your update dict code here \n        # your feature extraction and model training code here\n    previous_test_df = current_test.copy()\n    current_test = current_test[current_test.content_type_id == 0]\n    # your prediction code here\n    # Write all your Feature Extratcion using Dict Code Here , that is \n    # Code which  simply fetches user value from dict without updating\n    current_test['answered_correctly'] = model.predict(current_test[FEATS])\n    set_predict(current_test.loc[:,['row_id', 'answered_correctly']])\n    pbar.update(len(current_test))\n</code></pre>\n<p>[Note : Use Sample Size of 2.5 Million rows in that script only , otherwise you won't get a correct estimate of run time of your script ]<br>\nI noticed that my Feature generation code for the loop and prediction was showing more than 9 hours of estimated time . Moreover I got some error also related to LightGbm ! <strong>Also Note that none of this issues were visible while making Commit using env.predict method provided my RIIID Module , Hence I didn't noticed this</strong>. Now it became clear to me why Submission Error was coming in the first place. I will resolve this issues and make sure to make submission .</p>\n<p>TLDR: Commiting your Inference Script just on env.predict by RIIID Module  does not give you an indication whether your Inference Kernel will succeed on Private Test Set Re Run , Hence Don't rely on it . </p>\n<p>Hence for this competition a Workflow will be .<br>\n1) Add Features .<br>\n2) Train Model and Validate its performance.<br>\n3)<strong>[Very Important Step] Use Test Emulator Provided <a href=\"https://www.kaggle.com/its7171/time-series-api-iter-test-emulator\" target=\"_blank\">here</a> , to ensure that entire step for Feature Generation and Prediction , lies within 9 hours of Window  on 2.5 Million Rows .</strong><br>\n4) Once you are sure that your Script works fine , then only go for submission.<br>\n5) If your script is taking too much time to generate features consider dropping less important features .<br>\n6) Only Submit your inference kernel if your model along with Feature Generation is taking less than 9 hours on emulator .</p>\n<p>This competition is more about writing efficient code as much as it is about modelling ! If you face an error be patient debug it step by step rather than simply using brute force.</p>\n<p>I shared it so that anyone who is stuck on this issue can overcome it quickly and feel less frustruation 😀  , that comes on seeing <code>Submission Scoring Error</code>.</p>",
      "rawMarkdown": "Most of the points causing Submission Scoring Error are discussed [here ](https://www.kaggle.com/c/riiid-test-answer-prediction/discussion/192124) , However  I thought of reiterating over those points and remind participants of this topic . As it goes your submission or inference notebook should get run within 9 hours of run time . As pointed out by @sohier [here](https://www.kaggle.com/c/riiid-test-answer-prediction/discussion/196210) , this runtime is obfuscated with **Kernel rerun on test set time + Some Random Additional Time which never push the entire kernel rerun time beyond 9 hrs .**\nI was recently adding some features which were improving my Local Validation score significantly , but I was getting lots of **Submission Scoring Error** , Now I thought of debugging this issue step by step rather than solely relying on my submissions.\n\nEarlier I adopted this framework of flow.\n1) Add Features .\n2) Build Model\n3) Validate Cv Performance\n4) Build Inference Kernel !\n\nHowever As far as this competition is concerned this is the most unreliable and lot of `Submission Scoring Error` Prone Framework !\n\nEven though I knew about Time Series Emulator Api built by tito , I never used it ! I recently looked at it [here](https://www.kaggle.com/its7171/time-series-api-iter-test-emulator) , in that we have a code segment as follows \n\n```\npbar = tqdm(total=2500000)\nprevious_test_df = None\nfor (current_test, current_prediction_df) in iter_test:\n    if previous_test_df is not None:\n        answers = eval(current_test[\"prior_group_answers_correct\"].iloc[0])\n        responses = eval(current_test[\"prior_group_responses\"].iloc[0])\n        previous_test_df['answered_correctly'] = answers\n        previous_test_df['user_answer'] = responses\n        # Write all your update dict code here \n        # your feature extraction and model training code here\n    previous_test_df = current_test.copy()\n    current_test = current_test[current_test.content_type_id == 0]\n    # your prediction code here\n    # Write all your Feature Extratcion using Dict Code Here , that is \n    # Code which  simply fetches user value from dict without updating\n    current_test['answered_correctly'] = model.predict(current_test[FEATS])\n    set_predict(current_test.loc[:,['row_id', 'answered_correctly']])\n    pbar.update(len(current_test))\n```\n[Note : Use Sample Size of 2.5 Million rows in that script only , otherwise you won't get a correct estimate of run time of your script ]\nI noticed that my Feature generation code for the loop and prediction was showing more than 9 hours of estimated time . Moreover I got some error also related to LightGbm ! **Also Note that none of this issues were visible while making Commit using env.predict method provided my RIIID Module , Hence I didn't noticed this**. Now it became clear to me why Submission Error was coming in the first place. I will resolve this issues and make sure to make submission .\n\nTLDR: Commiting your Inference Script just on env.predict by RIIID Module  does not give you an indication whether your Inference Kernel will succeed on Private Test Set Re Run , Hence Don't rely on it . \n\nHence for this competition a Workflow will be .\n1) Add Features .\n2) Train Model and Validate its performance.\n3)**[Very Important Step] Use Test Emulator Provided [here](https://www.kaggle.com/its7171/time-series-api-iter-test-emulator) , to ensure that entire step for Feature Generation and Prediction , lies within 9 hours of Window  on 2.5 Million Rows .**\n4) Once you are sure that your Script works fine , then only go for submission.\n5) If your script is taking too much time to generate features consider dropping less important features .\n6) Only Submit your inference kernel if your model along with Feature Generation is taking less than 9 hours on emulator .\n\nThis competition is more about writing efficient code as much as it is about modelling ! If you face an error be patient debug it step by step rather than simply using brute force.\n\nI shared it so that anyone who is stuck on this issue can overcome it quickly and feel less frustruation 😀  , that comes on seeing `Submission Scoring Error`.",
      "votes": 2
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "1119539": "Most of the points causing Submission Scoring Error are discussed [here ](https://www.kaggle.com/c/riiid-test-answer-prediction/discussion/192124) , However  I thought of reiterating over those points and remind participants of this topic . As it goes your submission or inference notebook should get run within 9 hours of run time . As pointed out by @sohier [here](https://www.kaggle.com/c/riiid-test-answer-prediction/discussion/196210) , this runtime is obfuscated with **Kernel rerun on test set time + Some Random Additional Time which never push the entire kernel rerun time beyond 9 hrs .**\nI was recently adding some features which were improving my Local Validation score significantly , but I was getting lots of **Submission Scoring Error** , Now I thought of debugging this issue step by step rather than solely relying on my submissions.\n\nEarlier I adopted this framework of flow.\n1) Add Features .\n2) Build Model\n3) Validate Cv Performance\n4) Build Inference Kernel !\n\nHowever As far as this competition is concerned this is the most unreliable and lot of `Submission Scoring Error` Prone Framework !\n\nEven though I knew about Time Series Emulator Api built by tito , I never used it ! I recently looked at it [here](https://www.kaggle.com/its7171/time-series-api-iter-test-emulator) , in that we have a code segment as follows \n\n```\npbar = tqdm(total=2500000)\nprevious_test_df = None\nfor (current_test, current_prediction_df) in iter_test:\n    if previous_test_df is not None:\n        answers = eval(current_test[\"prior_group_answers_correct\"].iloc[0])\n        responses = eval(current_test[\"prior_group_responses\"].iloc[0])\n        previous_test_df['answered_correctly'] = answers\n        previous_test_df['user_answer'] = responses\n        # Write all your update dict code here \n        # your feature extraction and model training code here\n    previous_test_df = current_test.copy()\n    current_test = current_test[current_test.content_type_id == 0]\n    # your prediction code here\n    # Write all your Feature Extratcion using Dict Code Here , that is \n    # Code which  simply fetches user value from dict without updating\n    current_test['answered_correctly'] = model.predict(current_test[FEATS])\n    set_predict(current_test.loc[:,['row_id', 'answered_correctly']])\n    pbar.update(len(current_test))\n```\n[Note : Use Sample Size of 2.5 Million rows in that script only , otherwise you won't get a correct estimate of run time of your script ]\nI noticed that my Feature generation code for the loop and prediction was showing more than 9 hours of estimated time . Moreover I got some error also related to LightGbm ! **Also Note that none of this issues were visible while making Commit using env.predict method provided my RIIID Module , Hence I didn't noticed this**. Now it became clear to me why Submission Error was coming in the first place. I will resolve this issues and make sure to make submission .\n\nTLDR: Commiting your Inference Script just on env.predict by RIIID Module  does not give you an indication whether your Inference Kernel will succeed on Private Test Set Re Run , Hence Don't rely on it . \n\nHence for this competition a Workflow will be .\n1) Add Features .\n2) Train Model and Validate its performance.\n3)**[Very Important Step] Use Test Emulator Provided [here](https://www.kaggle.com/its7171/time-series-api-iter-test-emulator) , to ensure that entire step for Feature Generation and Prediction , lies within 9 hours of Window  on 2.5 Million Rows .**\n4) Once you are sure that your Script works fine , then only go for submission.\n5) If your script is taking too much time to generate features consider dropping less important features .\n6) Only Submit your inference kernel if your model along with Feature Generation is taking less than 9 hours on emulator .\n\nThis competition is more about writing efficient code as much as it is about modelling ! If you face an error be patient debug it step by step rather than simply using brute force.\n\nI shared it so that anyone who is stuck on this issue can overcome it quickly and feel less frustruation 😀  , that comes on seeing `Submission Scoring Error`."
  }
}