{
  "id": 198414,
  "title": " Avoid timeout !!",
  "url": "/competitions/riiid-test-answer-prediction/discussion/198414",
  "author_name": "Jude TCHAYE",
  "post_date": "2020-11-21T06:27:48.152000",
  "votes": 21,
  "comment_count": 4,
  "views": 0,
  "content": "<p>I know it is annoying to run a notebook for 9 hours and get an error. The following trick can be used to control your code runtime. The idea is: if the notebook fails to generate the submission file in the first 8hours we use the remaining time to complete everything:</p>\n<pre><code>import time\nstart_time= time.time()\nmax_time = 8*60*60 # max runtime\n\nfor (test_df, sample_prediction_df) in iter_test:\n    duration = time.time()-start_time\n    if duration &gt;  max_time:\n        test_df = test_df[test_df['content_type_id'] == 0]\n        test_df['answered_correctly'] = 0.5\n        env.predict(test_df[['row_id', 'answered_correctly']])\n    else:\n        # Your code\n</code></pre>",
  "messages": [
    {
      "id": 1085716,
      "postDate": "2020-11-21T06:27:48.153Z",
      "content": "<p>I know it is annoying to run a notebook for 9 hours and get an error. The following trick can be used to control your code runtime. The idea is: if the notebook fails to generate the submission file in the first 8hours we use the remaining time to complete everything:</p>\n<pre><code>import time\nstart_time= time.time()\nmax_time = 8*60*60 # max runtime\n\nfor (test_df, sample_prediction_df) in iter_test:\n    duration = time.time()-start_time\n    if duration &gt;  max_time:\n        test_df = test_df[test_df['content_type_id'] == 0]\n        test_df['answered_correctly'] = 0.5\n        env.predict(test_df[['row_id', 'answered_correctly']])\n    else:\n        # Your code\n</code></pre>",
      "rawMarkdown": "I know it is annoying to run a notebook for 9 hours and get an error. The following trick can be used to control your code runtime. The idea is: if the notebook fails to generate the submission file in the first 8hours we use the remaining time to complete everything:\n\n```\nimport time\nstart_time= time.time()\nmax_time = 8*60*60 # max runtime\n\nfor (test_df, sample_prediction_df) in iter_test:\n    duration = time.time()-start_time\n    if duration >  max_time:\n        test_df = test_df[test_df['content_type_id'] == 0]\n        test_df['answered_correctly'] = 0.5\n        env.predict(test_df[['row_id', 'answered_correctly']])\n    else:\n        # Your code\n```",
      "votes": 21
    },
    {
      "id": 1089028,
      "postDate": "2020-11-24T06:35:25.860Z",
      "content": "<p>It is very useful to explore more features.</p>",
      "rawMarkdown": "It is very useful to explore more features.",
      "votes": 2
    },
    {
      "id": 1087605,
      "postDate": "2020-11-22T22:43:44.670Z",
      "content": "<p>I think it's a good idea for the final run. But for debugging it can mask some errors.</p>",
      "rawMarkdown": "I think it's a good idea for the final run. But for debugging it can mask some errors.",
      "votes": 2,
      "replies": [
        {
          "id": 1087683,
          "postDate": "2020-11-23T01:44:58.917Z",
          "content": "<p>I think it only mask timeout.  It can be used when we're aware of it and still want to see how the code performs</p>",
          "rawMarkdown": "I think it only mask timeout.  It can be used when we're aware of it and still want to see how the code performs"
        }
      ]
    },
    {
      "id": 1088013,
      "postDate": "2020-11-23T08:37:37.797Z",
      "rawMarkdown": "",
      "votes": 1,
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 1089028,
      "author_name": "Zhenghan Chen",
      "author_url": "",
      "post_date": "2020-11-24T06:35:25.860000",
      "content": "<p>It is very useful to explore more features.</p>",
      "votes": 2,
      "replies": []
    },
    {
      "id": 1087605,
      "author_name": "Felipe Loque",
      "author_url": "",
      "post_date": "2020-11-22T22:43:44.670000",
      "content": "<p>I think it's a good idea for the final run. But for debugging it can mask some errors.</p>",
      "votes": 2,
      "replies": [
        {
          "id": 1087683,
          "author_name": "Jude TCHAYE",
          "author_url": "",
          "post_date": "2020-11-23T01:44:58.917000",
          "content": "<p>I think it only mask timeout.  It can be used when we're aware of it and still want to see how the code performs</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1088013,
      "author_name": "",
      "author_url": "",
      "post_date": "2020-11-23T08:37:37.797000",
      "content": "",
      "votes": 1,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1085716": "I know it is annoying to run a notebook for 9 hours and get an error. The following trick can be used to control your code runtime. The idea is: if the notebook fails to generate the submission file in the first 8hours we use the remaining time to complete everything:\n\n```\nimport time\nstart_time= time.time()\nmax_time = 8*60*60 # max runtime\n\nfor (test_df, sample_prediction_df) in iter_test:\n    duration = time.time()-start_time\n    if duration >  max_time:\n        test_df = test_df[test_df['content_type_id'] == 0]\n        test_df['answered_correctly'] = 0.5\n        env.predict(test_df[['row_id', 'answered_correctly']])\n    else:\n        # Your code\n```",
    "1089028": "It is very useful to explore more features.",
    "1087605": "I think it's a good idea for the final run. But for debugging it can mask some errors.",
    "1088013": ""
  }
}