{
  "id": 198842,
  "title": "Handling imbalanced datasets ",
  "url": "/competitions/cassava-leaf-disease-classification/discussion/198842",
  "author_name": "vinay",
  "post_date": "2020-11-23T09:01:16.048000",
  "votes": 2,
  "comment_count": 0,
  "views": 0,
  "content": "<p>As we can notice from the data that the training data is imbalanced<br>\nClass 0: 1087<br>\nClass 1: 2189<br>\nClass 2: 2386<br>\nClass 3: 13158<br>\nClass 4: 2577<br>\nOne best way to overcome this is to use data augmentation for the classes 0,1,2,4. There is a package in tensorflow called <a href=\"https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/ImageDataGenerator\" target=\"_blank\">ImageDataGenerator</a></p>\n<p>Sample code for data augumentation is:</p>\n<p>from keras.preprocessing.image import ImageDataGenerator<br>\ndatagen = ImageDataGenerator(<br>\n        rotation_range=10, # rotation<br>\n        width_shift_range=0.2, # horizontal shift<br>\n        height_shift_range=0.2, # vertical shift<br>\n        zoom_range=0.2, # zoom<br>\n        horizontal_flip=True,<br>\n        vertical_flip=True, # horizontal flip<br>\n        brightness_range=[0.2,1.2]) # brightness</p>",
  "messages": [
    {
      "id": 1088035,
      "postDate": "2020-11-23T09:01:16.050Z",
      "content": "<p>As we can notice from the data that the training data is imbalanced<br>\nClass 0: 1087<br>\nClass 1: 2189<br>\nClass 2: 2386<br>\nClass 3: 13158<br>\nClass 4: 2577<br>\nOne best way to overcome this is to use data augmentation for the classes 0,1,2,4. There is a package in tensorflow called <a href=\"https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/ImageDataGenerator\" target=\"_blank\">ImageDataGenerator</a></p>\n<p>Sample code for data augumentation is:</p>\n<p>from keras.preprocessing.image import ImageDataGenerator<br>\ndatagen = ImageDataGenerator(<br>\n        rotation_range=10, # rotation<br>\n        width_shift_range=0.2, # horizontal shift<br>\n        height_shift_range=0.2, # vertical shift<br>\n        zoom_range=0.2, # zoom<br>\n        horizontal_flip=True,<br>\n        vertical_flip=True, # horizontal flip<br>\n        brightness_range=[0.2,1.2]) # brightness</p>",
      "rawMarkdown": "As we can notice from the data that the training data is imbalanced\nClass 0: 1087\nClass 1: 2189\nClass 2: 2386\nClass 3: 13158\nClass 4: 2577\nOne best way to overcome this is to use data augmentation for the classes 0,1,2,4. There is a package in tensorflow called [ImageDataGenerator](https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/ImageDataGenerator)\n\nSample code for data augumentation is:\n\nfrom keras.preprocessing.image import ImageDataGenerator\ndatagen = ImageDataGenerator(\n        rotation_range=10, # rotation\n        width_shift_range=0.2, # horizontal shift\n        height_shift_range=0.2, # vertical shift\n        zoom_range=0.2, # zoom\n        horizontal_flip=True,\n        vertical_flip=True, # horizontal flip\n        brightness_range=[0.2,1.2]) # brightness\n\n",
      "votes": 2
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "1088035": "As we can notice from the data that the training data is imbalanced\nClass 0: 1087\nClass 1: 2189\nClass 2: 2386\nClass 3: 13158\nClass 4: 2577\nOne best way to overcome this is to use data augmentation for the classes 0,1,2,4. There is a package in tensorflow called [ImageDataGenerator](https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/ImageDataGenerator)\n\nSample code for data augumentation is:\n\nfrom keras.preprocessing.image import ImageDataGenerator\ndatagen = ImageDataGenerator(\n        rotation_range=10, # rotation\n        width_shift_range=0.2, # horizontal shift\n        height_shift_range=0.2, # vertical shift\n        zoom_range=0.2, # zoom\n        horizontal_flip=True,\n        vertical_flip=True, # horizontal flip\n        brightness_range=[0.2,1.2]) # brightness\n\n"
  }
}