{
  "id": 35306,
  "title": "Why am I getting accuracy 0 when predicting \"1\" all the time",
  "url": "/competitions/digit-recognizer/discussion/35306",
  "author_name": "Octavian",
  "post_date": "2017-06-26T14:27:04.127000",
  "votes": 0,
  "comment_count": 1,
  "views": null,
  "content": "<p>Just to see if I am writing to the correct output, I have this code:</p>\n\n<pre><code>f = open('results.csv', 'w')\nf.write(\"ImageId,Label\\n\")\nfor i in range(1, 28001):\n    f.write(\"{}, {}\\n\".format(i, 1))\n</code></pre>\n\n<p>I submitted this and I expected to have a something like a <code>0.1</code> accuracy.\nInstead, I got <code>0</code> accuracy.</p>\n\n<p>I think all the \"1\" labeled images should be predicted correctly.</p>\n\n<p>Then how come I am getting <code>0</code> accuracy?</p>",
  "messages": [
    {
      "id": 196182,
      "postDate": "2017-06-26T14:41:30.590Z",
      "content": "<p>Are you able to open your csv file and see all the 1s you've predicted?</p>\n\n<p>EDIT: <a href=\"https://www.kaggle.com/c/digit-recognizer/discussion/34864\">It might be because of the data type you're inputting</a></p>\n\n<p>Try doing something like this:</p>\n\n<pre><code>f = open('results.csv', 'w')\nf.write(\"ImageId,Label\\n\")\nfor i in range(1, 28001):\n    f.write(\"{}, {}\\n\".format(i, int(1)))\n</code></pre>\n\n<p>Here we explicitly state we want to input the 1s as integers, rather than strings or doubles or floats. Any difference?</p>",
      "rawMarkdown": "Are you able to open your csv file and see all the 1s you've predicted?\n\nEDIT: [It might be because of the data type you're inputting](https://www.kaggle.com/c/digit-recognizer/discussion/34864)\n\nTry doing something like this:\n\n    f = open('results.csv', 'w')\n    f.write(\"ImageId,Label\\n\")\n    for i in range(1, 28001):\n        f.write(\"{}, {}\\n\".format(i, int(1)))\n\nHere we explicitly state we want to input the 1s as integers, rather than strings or doubles or floats. Any difference?"
    },
    {
      "id": 196173,
      "postDate": "2017-06-26T14:27:04.127Z",
      "content": "<p>Just to see if I am writing to the correct output, I have this code:</p>\n\n<pre><code>f = open('results.csv', 'w')\nf.write(\"ImageId,Label\\n\")\nfor i in range(1, 28001):\n    f.write(\"{}, {}\\n\".format(i, 1))\n</code></pre>\n\n<p>I submitted this and I expected to have a something like a <code>0.1</code> accuracy.\nInstead, I got <code>0</code> accuracy.</p>\n\n<p>I think all the \"1\" labeled images should be predicted correctly.</p>\n\n<p>Then how come I am getting <code>0</code> accuracy?</p>",
      "rawMarkdown": "Just to see if I am writing to the correct output, I have this code:\n\n    f = open('results.csv', 'w')\n    f.write(\"ImageId,Label\\n\")\n    for i in range(1, 28001):\n        f.write(\"{}, {}\\n\".format(i, 1))\n\nI submitted this and I expected to have a something like a `0.1` accuracy.\nInstead, I got `0` accuracy.\n\nI think all the \"1\" labeled images should be predicted correctly.\n\nThen how come I am getting `0` accuracy?\n"
    }
  ],
  "comments": [
    {
      "id": 196182,
      "author_name": "Aypop Tosis",
      "author_url": "",
      "post_date": "2017-06-26T14:41:30.590000",
      "content": "<p>Are you able to open your csv file and see all the 1s you've predicted?</p>\n\n<p>EDIT: <a href=\"https://www.kaggle.com/c/digit-recognizer/discussion/34864\">It might be because of the data type you're inputting</a></p>\n\n<p>Try doing something like this:</p>\n\n<pre><code>f = open('results.csv', 'w')\nf.write(\"ImageId,Label\\n\")\nfor i in range(1, 28001):\n    f.write(\"{}, {}\\n\".format(i, int(1)))\n</code></pre>\n\n<p>Here we explicitly state we want to input the 1s as integers, rather than strings or doubles or floats. Any difference?</p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "196182": "Are you able to open your csv file and see all the 1s you've predicted?\n\nEDIT: [It might be because of the data type you're inputting](https://www.kaggle.com/c/digit-recognizer/discussion/34864)\n\nTry doing something like this:\n\n    f = open('results.csv', 'w')\n    f.write(\"ImageId,Label\\n\")\n    for i in range(1, 28001):\n        f.write(\"{}, {}\\n\".format(i, int(1)))\n\nHere we explicitly state we want to input the 1s as integers, rather than strings or doubles or floats. Any difference?",
    "196173": "Just to see if I am writing to the correct output, I have this code:\n\n    f = open('results.csv', 'w')\n    f.write(\"ImageId,Label\\n\")\n    for i in range(1, 28001):\n        f.write(\"{}, {}\\n\".format(i, 1))\n\nI submitted this and I expected to have a something like a `0.1` accuracy.\nInstead, I got `0` accuracy.\n\nI think all the \"1\" labeled images should be predicted correctly.\n\nThen how come I am getting `0` accuracy?\n"
  }
}