{
  "id": 402507,
  "title": "Has the format of the sample_submission in iter_test changed?",
  "url": "/competitions/predict-student-performance-from-game-play/discussion/402507",
  "author_name": "",
  "post_date": "2023-04-18T17:00:45.904093900Z",
  "votes": 4,
  "comment_count": 1,
  "views": 0,
  "content": "<p>\" for (test, sample_submission) in iter_test: \" </p>\n<p>Has the data structure of the sample_submission generated by 'iter_test' changed?<br>\nThe process of predicting testset data and transferring the results to the sample_submission, which had been working without any problems, is suddenly encountering errors…</p>\n<p>Here is my code…<br>\nThis code produces a \"ValueError: Must have equal len keys and value when setting with an iterable error\"</p>\n<pre><code>limits = {:(,), :(,), :(,)}\npre_submissions = []\n (test, sample_submission)  iter_test :\n\n    grp = test.level_group.values[]\n    a,b = limits[grp]\n\n    test.drop(columns = [, , ], axis = , inplace = )\n    test = preprocess_test(test, columns, grp, pre_submissions)\n\n     q  (a, b) :\n\n        ()\n        xgb = best_model[]\n\n        non_features = [item  item  feature_true[q-]  item   (test.columns)]\n        test[non_features] = np.zeros([(test), (non_features)])\n\n        pred_proba = xgb.predict_proba(test[feature_true[q-]])[:, ]\n        pred = (pred_proba &gt; best_thr).astype()\n\n        mask = sample_submission.session_id..contains()\n        sample_submission.loc[mask, ] = pred\n\n    pre_submissions.append(sample_submission.copy())\n\n    env.predict(sample_submission)\n    ()\n</code></pre>",
  "messages": [
    {
      "id": "2226117",
      "postDate": "04/18/2023 17:00:45",
      "content": "<p>\" for (test, sample_submission) in iter_test: \" </p>\n<p>Has the data structure of the sample_submission generated by 'iter_test' changed?<br>\nThe process of predicting testset data and transferring the results to the sample_submission, which had been working without any problems, is suddenly encountering errors…</p>\n<p>Here is my code…<br>\nThis code produces a \"ValueError: Must have equal len keys and value when setting with an iterable error\"</p>\n<pre><code>limits = {:(,), :(,), :(,)}\npre_submissions = []\n (test, sample_submission)  iter_test :\n\n    grp = test.level_group.values[]\n    a,b = limits[grp]\n\n    test.drop(columns = [, , ], axis = , inplace = )\n    test = preprocess_test(test, columns, grp, pre_submissions)\n\n     q  (a, b) :\n\n        ()\n        xgb = best_model[]\n\n        non_features = [item  item  feature_true[q-]  item   (test.columns)]\n        test[non_features] = np.zeros([(test), (non_features)])\n\n        pred_proba = xgb.predict_proba(test[feature_true[q-]])[:, ]\n        pred = (pred_proba &gt; best_thr).astype()\n\n        mask = sample_submission.session_id..contains()\n        sample_submission.loc[mask, ] = pred\n\n    pre_submissions.append(sample_submission.copy())\n\n    env.predict(sample_submission)\n    ()\n</code></pre>",
      "rawMarkdown": "\" for (test, sample_submission) in iter_test: \" \n\nHas the data structure of the sample_submission generated by 'iter_test' changed?\nThe process of predicting testset data and transferring the results to the sample_submission, which had been working without any problems, is suddenly encountering errors...\n\nHere is my code...\nThis code produces a \"ValueError: Must have equal len keys and value when setting with an iterable error\"\n\n```python\n\nlimits = {'0-4':(1,4), '5-12':(4,14), '13-22':(14,19)}\npre_submissions = []\nfor (test, sample_submission) in iter_test :\n    \n    grp = test.level_group.values[0]\n    a,b = limits[grp]\n        \n    test.drop(columns = [\"fullscreen\", \"hq\", \"music\"], axis = 1, inplace = True)\n    test = preprocess_test(test, columns, grp, pre_submissions)\n\n    for q in range(a, b) :\n        \n        print(f\" Predict Q{q} ... \")\n        xgb = best_model[f\"Q{q}\"]\n        \n        non_features = [item for item in feature_true[q-1] if item not in list(test.columns)]\n        test[non_features] = np.zeros([len(test), len(non_features)])\n        \n        pred_proba = xgb.predict_proba(test[feature_true[q-1]])[:, 1]\n        pred = (pred_proba > best_thr).astype(\"int16\")\n        \n        mask = sample_submission.session_id.str.contains(f\"q{q}\")\n        sample_submission.loc[mask, \"correct\"] = pred\n        \n    pre_submissions.append(sample_submission.copy())\n    \n    env.predict(sample_submission)\n    print(f\"Predicting Level {grp} Was Done.\\n\")\n```",
      "votes": null
    },
    {
      "id": "2226259",
      "postDate": "04/18/2023 19:31:33",
      "content": "<p></p>\n<p>Never mind, I don't think there was any change yesterday, just that I had some bug in my code :D</p>",
      "rawMarkdown": "~~I think they've just changed it today, now the sample submission is in its correct format.~~\n\nNever mind, I don't think there was any change yesterday, just that I had some bug in my code :D",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2226259,
      "author_name": "woprime",
      "author_url": "",
      "post_date": "04/18/2023 19:31:33",
      "content": "<p></p>\n<p>Never mind, I don't think there was any change yesterday, just that I had some bug in my code :D</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2226117": "\" for (test, sample_submission) in iter_test: \" \n\nHas the data structure of the sample_submission generated by 'iter_test' changed?\nThe process of predicting testset data and transferring the results to the sample_submission, which had been working without any problems, is suddenly encountering errors...\n\nHere is my code...\nThis code produces a \"ValueError: Must have equal len keys and value when setting with an iterable error\"\n\n```python\n\nlimits = {'0-4':(1,4), '5-12':(4,14), '13-22':(14,19)}\npre_submissions = []\nfor (test, sample_submission) in iter_test :\n    \n    grp = test.level_group.values[0]\n    a,b = limits[grp]\n        \n    test.drop(columns = [\"fullscreen\", \"hq\", \"music\"], axis = 1, inplace = True)\n    test = preprocess_test(test, columns, grp, pre_submissions)\n\n    for q in range(a, b) :\n        \n        print(f\" Predict Q{q} ... \")\n        xgb = best_model[f\"Q{q}\"]\n        \n        non_features = [item for item in feature_true[q-1] if item not in list(test.columns)]\n        test[non_features] = np.zeros([len(test), len(non_features)])\n        \n        pred_proba = xgb.predict_proba(test[feature_true[q-1]])[:, 1]\n        pred = (pred_proba > best_thr).astype(\"int16\")\n        \n        mask = sample_submission.session_id.str.contains(f\"q{q}\")\n        sample_submission.loc[mask, \"correct\"] = pred\n        \n    pre_submissions.append(sample_submission.copy())\n    \n    env.predict(sample_submission)\n    print(f\"Predicting Level {grp} Was Done.\\n\")\n```",
    "2226259": "~~I think they've just changed it today, now the sample submission is in its correct format.~~\n\nNever mind, I don't think there was any change yesterday, just that I had some bug in my code :D"
  },
  "source": "meta"
}