{
  "id": 401991,
  "title": "Is iter_test iter ?",
  "url": "/competitions/predict-student-performance-from-game-play/discussion/401991",
  "author_name": "",
  "post_date": "2023-04-16T08:24:16.612447100Z",
  "votes": 2,
  "comment_count": 3,
  "views": 0,
  "content": "<p>this is my code ` #Get the test data and sample submission objects<br>\niter_test = env.iter_test()<br>\n(test, sample_submission) = next(iter_test)</p>\n<h1>Loop over the test data and sample submission</h1>\n<p>while True:</p>\n<pre><code># FEATURE ENGINEER TEST DATA\npre_data= feature_engineer(test)\ndf=coordination(pre_test)\n\n# INFER TEST DATA\ngrp = test.level_group.values[0]\na,b = limits[grp]\nfor t in range(a,b):\n    clf = models[f'{grp}_{t}']\n    p = clf.predict_proba(df[FEATURES].astype('float32'))[0,1]\n    mask = sample_submission.session_id.str.contains(f'q{t}')\n    sample_submission.loc[mask,'correct'] = int( p &gt; best_threshold )\n\nenv.predict(sample_submission)\n\ntry:\n    (test, sample_submission) = next(iter_test)\nexcept StopIteration:\n    break\n</code></pre>\n<p>` I copied this code from<a href=\"https://www.kaggle.com/code/cdeotte/xgboost-baseline-0-680\" target=\"_blank\">XGBoost Baseline - [0.680]</a> <br>\nbut An error happened <br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F10640570%2F387e956e0124b5537a60015c24c99dc1%2F2023-04-16.png?generation=1681633667430347&amp;alt=media\" alt=\"\"><br>\nwhy iter_test() can iterate once? <br>\nplease solve it!</p>",
  "messages": [
    {
      "id": "2223411",
      "postDate": "04/16/2023 08:24:16",
      "content": "<p>this is my code ` #Get the test data and sample submission objects<br>\niter_test = env.iter_test()<br>\n(test, sample_submission) = next(iter_test)</p>\n<h1>Loop over the test data and sample submission</h1>\n<p>while True:</p>\n<pre><code># FEATURE ENGINEER TEST DATA\npre_data= feature_engineer(test)\ndf=coordination(pre_test)\n\n# INFER TEST DATA\ngrp = test.level_group.values[0]\na,b = limits[grp]\nfor t in range(a,b):\n    clf = models[f'{grp}_{t}']\n    p = clf.predict_proba(df[FEATURES].astype('float32'))[0,1]\n    mask = sample_submission.session_id.str.contains(f'q{t}')\n    sample_submission.loc[mask,'correct'] = int( p &gt; best_threshold )\n\nenv.predict(sample_submission)\n\ntry:\n    (test, sample_submission) = next(iter_test)\nexcept StopIteration:\n    break\n</code></pre>\n<p>` I copied this code from<a href=\"https://www.kaggle.com/code/cdeotte/xgboost-baseline-0-680\" target=\"_blank\">XGBoost Baseline - [0.680]</a> <br>\nbut An error happened <br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F10640570%2F387e956e0124b5537a60015c24c99dc1%2F2023-04-16.png?generation=1681633667430347&amp;alt=media\" alt=\"\"><br>\nwhy iter_test() can iterate once? <br>\nplease solve it!</p>",
      "rawMarkdown": "this is my code ` #Get the test data and sample submission objects\niter_test = env.iter_test()\n(test, sample_submission) = next(iter_test)\n\n# Loop over the test data and sample submission\nwhile True:\n    \n    # FEATURE ENGINEER TEST DATA\n    pre_data= feature_engineer(test)\n    df=coordination(pre_test)\n    \n    # INFER TEST DATA\n    grp = test.level_group.values[0]\n    a,b = limits[grp]\n    for t in range(a,b):\n        clf = models[f'{grp}_{t}']\n        p = clf.predict_proba(df[FEATURES].astype('float32'))[0,1]\n        mask = sample_submission.session_id.str.contains(f'q{t}')\n        sample_submission.loc[mask,'correct'] = int( p > best_threshold )\n\n    env.predict(sample_submission)\n    \n    try:\n        (test, sample_submission) = next(iter_test)\n    except StopIteration:\n        break\n` I copied this code from[XGBoost Baseline - [0.680]](https://www.kaggle.com/code/cdeotte/xgboost-baseline-0-680) \nbut An error happened \n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F10640570%2F387e956e0124b5537a60015c24c99dc1%2F2023-04-16.png?generation=1681633667430347&alt=media)\nwhy iter_test() can iterate once? \nplease solve it!",
      "votes": null
    },
    {
      "id": "2223917",
      "postDate": "04/16/2023 19:10:25",
      "content": "<p>Restarting the kernel might solve this issue.</p>",
      "rawMarkdown": "Restarting the kernel might solve this issue.",
      "votes": null
    },
    {
      "id": "2226335",
      "postDate": "04/18/2023 20:59:50",
      "content": "<p>Either restart the notebook or either reset the object (you can change the global variable in it so it would start again.. there are some past competitions where people did this)</p>\n<p>The Devastator.</p>",
      "rawMarkdown": "Either restart the notebook or either reset the object (you can change the global variable in it so it would start again.. there are some past competitions where people did this)\n\n\nThe Devastator.",
      "votes": null
    },
    {
      "id": "2271827",
      "postDate": "05/24/2023 06:39:05",
      "content": "<p>thanks. I solved it by your tip!</p>",
      "rawMarkdown": "thanks. I solved it by your tip!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2223917,
      "author_name": "thaweewatboy",
      "author_url": "",
      "post_date": "04/16/2023 19:10:25",
      "content": "<p>Restarting the kernel might solve this issue.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 2226335,
      "author_name": "thedevastator",
      "author_url": "",
      "post_date": "04/18/2023 20:59:50",
      "content": "<p>Either restart the notebook or either reset the object (you can change the global variable in it so it would start again.. there are some past competitions where people did this)</p>\n<p>The Devastator.</p>",
      "votes": null,
      "replies": [
        {
          "id": 2271827,
          "author_name": "yoshitown",
          "author_url": "",
          "post_date": "05/24/2023 06:39:05",
          "content": "<p>thanks. I solved it by your tip!</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2223411": "this is my code ` #Get the test data and sample submission objects\niter_test = env.iter_test()\n(test, sample_submission) = next(iter_test)\n\n# Loop over the test data and sample submission\nwhile True:\n    \n    # FEATURE ENGINEER TEST DATA\n    pre_data= feature_engineer(test)\n    df=coordination(pre_test)\n    \n    # INFER TEST DATA\n    grp = test.level_group.values[0]\n    a,b = limits[grp]\n    for t in range(a,b):\n        clf = models[f'{grp}_{t}']\n        p = clf.predict_proba(df[FEATURES].astype('float32'))[0,1]\n        mask = sample_submission.session_id.str.contains(f'q{t}')\n        sample_submission.loc[mask,'correct'] = int( p > best_threshold )\n\n    env.predict(sample_submission)\n    \n    try:\n        (test, sample_submission) = next(iter_test)\n    except StopIteration:\n        break\n` I copied this code from[XGBoost Baseline - [0.680]](https://www.kaggle.com/code/cdeotte/xgboost-baseline-0-680) \nbut An error happened \n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F10640570%2F387e956e0124b5537a60015c24c99dc1%2F2023-04-16.png?generation=1681633667430347&alt=media)\nwhy iter_test() can iterate once? \nplease solve it!",
    "2223917": "Restarting the kernel might solve this issue.",
    "2226335": "Either restart the notebook or either reset the object (you can change the global variable in it so it would start again.. there are some past competitions where people did this)\n\n\nThe Devastator.",
    "2271827": "thanks. I solved it by your tip!"
  },
  "source": "meta"
}