{
  "id": 12585,
  "title": "How do you deal with the class unbalance for your CNN model?",
  "url": "/competitions/datasciencebowl/discussion/12585",
  "author_name": "",
  "post_date": "2015-02-21T22:46:20.247Z",
  "votes": null,
  "comment_count": 5,
  "views": 1903,
  "content": "<p>As I observed from the train data, there is a very large class unbalance as you can see (at least sense :) ) from the attached&nbsp;graph. Hence how would you deal such class distribution with Conv Neural Networks? Any ideas.</p>",
  "messages": [
    {
      "id": "64722",
      "postDate": "02/21/2015 22:46:20",
      "content": "<p>As I observed from the train data, there is a very large class unbalance as you can see (at least sense :) ) from the attached&nbsp;graph. Hence how would you deal such class distribution with Conv Neural Networks? Any ideas.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "64724",
      "postDate": "02/22/2015 02:19:48",
      "content": "<p>You don't have to as long as the training data has the same distribution as the test data.</p>\n<p>The neural net will learn the distributions. &nbsp;</p>\n<p>I did try to do equal sampling of the data early on. &nbsp;It wasn't horrible but there was little to be gained. &nbsp;If you do try something like that you need to remember to multiply the outputs of the neural net by the prior probabilities of each class.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "65654",
      "postDate": "03/07/2015 00:09:43",
      "content": "<p>You mean the &quot;validation&quot; data?</p>\n<p>How one would know about the test data distribution?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "65655",
      "postDate": "03/07/2015 00:45:54",
      "content": "<p>[quote=knarfben;65654]</p>\n<p>You mean the &quot;validation&quot; data?</p>\n<p>How one would know about the test data distribution?</p>\n<p>[/quote]</p>\n<p>You just assume that the&nbsp;prior probability of a class in the training data is the same as in the test data.</p>\n<p>But simply put, your network will output better scores if you don't change the frequency&nbsp;of your training data classes in any way. &nbsp;ie during a training epoch your network should see 71 acantharia_protist_halo examples and 889 acantharia protist examples. &nbsp;</p>\n<p>I tried equal&nbsp;class representation early on and multiplying the output by the prior probabilities improved the score. But my scores were much improved by not changing the frequency&nbsp;of classes during training.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "65656",
      "postDate": "03/07/2015 00:54:44",
      "content": "<p>Si you didnt even use any augmentation techniques to get your actual score?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "65657",
      "postDate": "03/07/2015 02:19:33",
      "content": "<p>[quote=knarfben;65656]</p>\n<p>Si you didnt even use any augmentation techniques to get your actual score?</p>\n<p>[/quote]</p>\n\n<p>I augment the training set. &nbsp;I just don't change the class frequencies.</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 64724,
      "author_name": "iamthep",
      "author_url": "",
      "post_date": "02/22/2015 02:19:48",
      "content": "<p>You don't have to as long as the training data has the same distribution as the test data.</p>\n<p>The neural net will learn the distributions. &nbsp;</p>\n<p>I did try to do equal sampling of the data early on. &nbsp;It wasn't horrible but there was little to be gained. &nbsp;If you do try something like that you need to remember to multiply the outputs of the neural net by the prior probabilities of each class.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 65654,
      "author_name": "knarfben",
      "author_url": "",
      "post_date": "03/07/2015 00:09:43",
      "content": "<p>You mean the &quot;validation&quot; data?</p>\n<p>How one would know about the test data distribution?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 65655,
      "author_name": "iamthep",
      "author_url": "",
      "post_date": "03/07/2015 00:45:54",
      "content": "<p>[quote=knarfben;65654]</p>\n<p>You mean the &quot;validation&quot; data?</p>\n<p>How one would know about the test data distribution?</p>\n<p>[/quote]</p>\n<p>You just assume that the&nbsp;prior probability of a class in the training data is the same as in the test data.</p>\n<p>But simply put, your network will output better scores if you don't change the frequency&nbsp;of your training data classes in any way. &nbsp;ie during a training epoch your network should see 71 acantharia_protist_halo examples and 889 acantharia protist examples. &nbsp;</p>\n<p>I tried equal&nbsp;class representation early on and multiplying the output by the prior probabilities improved the score. But my scores were much improved by not changing the frequency&nbsp;of classes during training.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 65656,
      "author_name": "knarfben",
      "author_url": "",
      "post_date": "03/07/2015 00:54:44",
      "content": "<p>Si you didnt even use any augmentation techniques to get your actual score?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 65657,
      "author_name": "iamthep",
      "author_url": "",
      "post_date": "03/07/2015 02:19:33",
      "content": "<p>[quote=knarfben;65656]</p>\n<p>Si you didnt even use any augmentation techniques to get your actual score?</p>\n<p>[/quote]</p>\n\n<p>I augment the training set. &nbsp;I just don't change the class frequencies.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "64722": "",
    "64724": "",
    "65654": "",
    "65655": "",
    "65656": "",
    "65657": ""
  },
  "source": "meta"
}