{
  "id": 242755,
  "title": "How to get a top 1% scoring solution with no ensembles",
  "url": "/competitions/diabetic-retinopathy-detection/discussion/242755",
  "author_name": "",
  "post_date": "2021-05-30T14:45:13.003812400Z",
  "votes": 28,
  "comment_count": 4,
  "views": 0,
  "content": "<p>For practice I tried to obtain a high score on this competition, obviously it's not fair since there's been a lot of advances since the deadline of the comeptition but nevertheless I think my solution is quite simple and obtains a top 1% solution in the leaderboard with a single model and no ensemble. </p>\n<p>I've created a YouTube video of me detailing each step of the solution: <br>\n<a href=\"https://youtu.be/YxQYvhap3kE\" target=\"_blank\">https://youtu.be/YxQYvhap3kE</a></p>\n<p>Here is the GitHub code:<br>\n<a href=\"https://github.com/aladdinpersson/Machine-Learning-Collection/tree/master/ML/Kaggles/DiabeticRetinopathy\" target=\"_blank\">https://github.com/aladdinpersson/Machine-Learning-Collection/tree/master/ML/Kaggles/DiabeticRetinopathy</a></p>\n<p>But let me also do a quick summary of what works (and what didn't for me). I first did a baseline solution with EfficientNet-B3 and image size of 120x120 in order for relatively quick iterations.</p>\n<p>BASELINE (B3, 120x120 image resolution):</p>\n<ul>\n<li>Val score: 0.55</li>\n<li>Public score: 0.52648</li>\n</ul>\n<p>I then added preprocessing of the images by removing the black borders and maining the aspect ratio of each.</p>\n<ul>\n<li>Preprocess the images:</li>\n<li>Val score: 0.60 (+0.05)</li>\n</ul>\n<p>I then improved the loss function, first I used CrossEntropyLoss but since this doesn't correspond very well to the QuadraticWeightedKappa score, I changed to MSE.</p>\n<ul>\n<li><p>Improve the loss function (MSE -&gt; convert to integer predictions):</p></li>\n<li><p>Val score: 0.65 (+0.05)</p></li>\n<li><p>Get balanced data loader (Didn't work for me)<br>\n(class_weights=[1,2,2,2,2] -&gt; Doesn't work either)</p></li>\n<li><p>Heavy data augmentation (for some odd reason, this didn't work?)</p></li>\n<li><p>Val score: 0.63 (-0.02)</p></li>\n</ul>\n<p>Weird that we didn't get an improvement here. Thinking maybe it's the<br>\nimage size, maybe using some bad augmentation?</p>\n<ul>\n<li><p>Blending (Left and Right eye information)</p></li>\n<li><p>Val score: 0.67 (+0.02)</p></li>\n<li><p>Increase image resolution<br>\nRes 300x300: 0.736 (+0.08)<br>\nRes 500x500: 0.787 (+0.05)<br>\nRes 728x728: 0.837 (+0.05)</p></li>\n</ul>\n<p>Then using left and right eye information and trained the small neural network on top of it got me:<br>\nPublic score: 0.84613<br>\nPrivate score: 0.83880</p>\n<p>Ideas for improving further:</p>\n<ul>\n<li>Train on the validation data (4000 examples)</li>\n<li>Larger model (B4,B5,B6,B7?)</li>\n<li>Larger image resolution</li>\n<li>Better data augmentations method (Randaugment?)</li>\n<li>Ensemble for the blending model (fast to train)</li>\n<li>Ensemble of various CNN models</li>\n<li>Tweaking hyperparameters</li>\n<li>Better loss function, better proxy for WeightedKappa</li>\n<li>? Comment ideas below</li>\n</ul>",
  "messages": [
    {
      "id": "1328803",
      "postDate": "05/30/2021 14:45:13",
      "content": "<p>For practice I tried to obtain a high score on this competition, obviously it's not fair since there's been a lot of advances since the deadline of the comeptition but nevertheless I think my solution is quite simple and obtains a top 1% solution in the leaderboard with a single model and no ensemble. </p>\n<p>I've created a YouTube video of me detailing each step of the solution: <br>\n<a href=\"https://youtu.be/YxQYvhap3kE\" target=\"_blank\">https://youtu.be/YxQYvhap3kE</a></p>\n<p>Here is the GitHub code:<br>\n<a href=\"https://github.com/aladdinpersson/Machine-Learning-Collection/tree/master/ML/Kaggles/DiabeticRetinopathy\" target=\"_blank\">https://github.com/aladdinpersson/Machine-Learning-Collection/tree/master/ML/Kaggles/DiabeticRetinopathy</a></p>\n<p>But let me also do a quick summary of what works (and what didn't for me). I first did a baseline solution with EfficientNet-B3 and image size of 120x120 in order for relatively quick iterations.</p>\n<p>BASELINE (B3, 120x120 image resolution):</p>\n<ul>\n<li>Val score: 0.55</li>\n<li>Public score: 0.52648</li>\n</ul>\n<p>I then added preprocessing of the images by removing the black borders and maining the aspect ratio of each.</p>\n<ul>\n<li>Preprocess the images:</li>\n<li>Val score: 0.60 (+0.05)</li>\n</ul>\n<p>I then improved the loss function, first I used CrossEntropyLoss but since this doesn't correspond very well to the QuadraticWeightedKappa score, I changed to MSE.</p>\n<ul>\n<li><p>Improve the loss function (MSE -&gt; convert to integer predictions):</p></li>\n<li><p>Val score: 0.65 (+0.05)</p></li>\n<li><p>Get balanced data loader (Didn't work for me)<br>\n(class_weights=[1,2,2,2,2] -&gt; Doesn't work either)</p></li>\n<li><p>Heavy data augmentation (for some odd reason, this didn't work?)</p></li>\n<li><p>Val score: 0.63 (-0.02)</p></li>\n</ul>\n<p>Weird that we didn't get an improvement here. Thinking maybe it's the<br>\nimage size, maybe using some bad augmentation?</p>\n<ul>\n<li><p>Blending (Left and Right eye information)</p></li>\n<li><p>Val score: 0.67 (+0.02)</p></li>\n<li><p>Increase image resolution<br>\nRes 300x300: 0.736 (+0.08)<br>\nRes 500x500: 0.787 (+0.05)<br>\nRes 728x728: 0.837 (+0.05)</p></li>\n</ul>\n<p>Then using left and right eye information and trained the small neural network on top of it got me:<br>\nPublic score: 0.84613<br>\nPrivate score: 0.83880</p>\n<p>Ideas for improving further:</p>\n<ul>\n<li>Train on the validation data (4000 examples)</li>\n<li>Larger model (B4,B5,B6,B7?)</li>\n<li>Larger image resolution</li>\n<li>Better data augmentations method (Randaugment?)</li>\n<li>Ensemble for the blending model (fast to train)</li>\n<li>Ensemble of various CNN models</li>\n<li>Tweaking hyperparameters</li>\n<li>Better loss function, better proxy for WeightedKappa</li>\n<li>? Comment ideas below</li>\n</ul>",
      "rawMarkdown": "For practice I tried to obtain a high score on this competition, obviously it's not fair since there's been a lot of advances since the deadline of the comeptition but nevertheless I think my solution is quite simple and obtains a top 1% solution in the leaderboard with a single model and no ensemble. \n\nI've created a YouTube video of me detailing each step of the solution: \nhttps://youtu.be/YxQYvhap3kE\n\nHere is the GitHub code:\nhttps://github.com/aladdinpersson/Machine-Learning-Collection/tree/master/ML/Kaggles/DiabeticRetinopathy\n\nBut let me also do a quick summary of what works (and what didn't for me). I first did a baseline solution with EfficientNet-B3 and image size of 120x120 in order for relatively quick iterations.\n\nBASELINE (B3, 120x120 image resolution):\n* Val score: 0.55\n* Public score: 0.52648\n\nI then added preprocessing of the images by removing the black borders and maining the aspect ratio of each.\n\n+ Preprocess the images:\n* Val score: 0.60 (+0.05)\n\nI then improved the loss function, first I used CrossEntropyLoss but since this doesn't correspond very well to the QuadraticWeightedKappa score, I changed to MSE.\n\n+ Improve the loss function (MSE -> convert to integer predictions):\n* Val score: 0.65 (+0.05)\n\n+ Get balanced data loader (Didn't work for me)\n(class_weights=[1,2,2,2,2] -> Doesn't work either)\n\n+ Heavy data augmentation (for some odd reason, this didn't work?)\n* Val score: 0.63 (-0.02)\n\nWeird that we didn't get an improvement here. Thinking maybe it's the\nimage size, maybe using some bad augmentation?\n\n+ Blending (Left and Right eye information)\n* Val score: 0.67 (+0.02)\n\n+ Increase image resolution\nRes 300x300: 0.736 (+0.08)\nRes 500x500: 0.787 (+0.05)\nRes 728x728: 0.837 (+0.05)\n\nThen using left and right eye information and trained the small neural network on top of it got me:\nPublic score: 0.84613\nPrivate score: 0.83880\n\nIdeas for improving further:\n* Train on the validation data (4000 examples)\n* Larger model (B4,B5,B6,B7?)\n* Larger image resolution\n* Better data augmentations method (Randaugment?)\n* Ensemble for the blending model (fast to train)\n* Ensemble of various CNN models\n* Tweaking hyperparameters\n* Better loss function, better proxy for WeightedKappa\n* ? Comment ideas below",
      "votes": null
    },
    {
      "id": "1339533",
      "postDate": "06/07/2021 09:59:31",
      "content": "<p>Hey <a href=\"https://www.kaggle.com/aladdinpersson\" target=\"_blank\">@aladdinpersson</a>, really nice video. <br>\nI wanted to know how to load/train with such huge data, like in this case 83GB? I have seen few competitions with more than 50GB of data, how to deal with this?</p>",
      "rawMarkdown": "Hey @aladdinpersson, really nice video. \nI wanted to know how to load/train with such huge data, like in this case 83GB? I have seen few competitions with more than 50GB of data, how to deal with this?",
      "votes": null
    },
    {
      "id": "1345104",
      "postDate": "06/11/2021 10:04:58",
      "content": "<p><a href=\"https://www.kaggle.com/aladdinpersson\" target=\"_blank\">@aladdinpersson</a>  Thank you for the great ideas you gave us, I have an extra idea here. Can you show us how we can use  Ben Graham(Competition winner) pre-processing method (specially color version) and train the model from different transfer learning models? I think this way the result will be improved more. </p>",
      "rawMarkdown": "aladdinpersson  Thank you for the great ideas you gave us, I have an extra idea here. Can you show us how we can use  Ben Graham(Competition winner) pre-processing method (specially color version) and train the model from different transfer learning models? I think this way the result will be improved more.",
      "votes": null
    },
    {
      "id": "1383942",
      "postDate": "07/11/2021 11:08:46",
      "content": "<p>How many epochs and how long did it take to train if i may ask?</p>",
      "rawMarkdown": "How many epochs and how long did it take to train if i may ask?",
      "votes": null
    },
    {
      "id": "2142439",
      "postDate": "02/13/2023 14:28:33",
      "content": "<p>thank you for making video with such detailed explanation</p>",
      "rawMarkdown": "thank you for making video with such detailed explanation",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1339533,
      "author_name": "abdulwaheedsoudagar",
      "author_url": "",
      "post_date": "06/07/2021 09:59:31",
      "content": "<p>Hey <a href=\"https://www.kaggle.com/aladdinpersson\" target=\"_blank\">@aladdinpersson</a>, really nice video. <br>\nI wanted to know how to load/train with such huge data, like in this case 83GB? I have seen few competitions with more than 50GB of data, how to deal with this?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1345104,
      "author_name": "unitedethiopia",
      "author_url": "",
      "post_date": "06/11/2021 10:04:58",
      "content": "<p><a href=\"https://www.kaggle.com/aladdinpersson\" target=\"_blank\">@aladdinpersson</a>  Thank you for the great ideas you gave us, I have an extra idea here. Can you show us how we can use  Ben Graham(Competition winner) pre-processing method (specially color version) and train the model from different transfer learning models? I think this way the result will be improved more. </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1383942,
      "author_name": "mahmoudlimam",
      "author_url": "",
      "post_date": "07/11/2021 11:08:46",
      "content": "<p>How many epochs and how long did it take to train if i may ask?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 2142439,
      "author_name": "anastasiiarepalo",
      "author_url": "",
      "post_date": "02/13/2023 14:28:33",
      "content": "<p>thank you for making video with such detailed explanation</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1328803": "For practice I tried to obtain a high score on this competition, obviously it's not fair since there's been a lot of advances since the deadline of the comeptition but nevertheless I think my solution is quite simple and obtains a top 1% solution in the leaderboard with a single model and no ensemble. \n\nI've created a YouTube video of me detailing each step of the solution: \nhttps://youtu.be/YxQYvhap3kE\n\nHere is the GitHub code:\nhttps://github.com/aladdinpersson/Machine-Learning-Collection/tree/master/ML/Kaggles/DiabeticRetinopathy\n\nBut let me also do a quick summary of what works (and what didn't for me). I first did a baseline solution with EfficientNet-B3 and image size of 120x120 in order for relatively quick iterations.\n\nBASELINE (B3, 120x120 image resolution):\n* Val score: 0.55\n* Public score: 0.52648\n\nI then added preprocessing of the images by removing the black borders and maining the aspect ratio of each.\n\n+ Preprocess the images:\n* Val score: 0.60 (+0.05)\n\nI then improved the loss function, first I used CrossEntropyLoss but since this doesn't correspond very well to the QuadraticWeightedKappa score, I changed to MSE.\n\n+ Improve the loss function (MSE -> convert to integer predictions):\n* Val score: 0.65 (+0.05)\n\n+ Get balanced data loader (Didn't work for me)\n(class_weights=[1,2,2,2,2] -> Doesn't work either)\n\n+ Heavy data augmentation (for some odd reason, this didn't work?)\n* Val score: 0.63 (-0.02)\n\nWeird that we didn't get an improvement here. Thinking maybe it's the\nimage size, maybe using some bad augmentation?\n\n+ Blending (Left and Right eye information)\n* Val score: 0.67 (+0.02)\n\n+ Increase image resolution\nRes 300x300: 0.736 (+0.08)\nRes 500x500: 0.787 (+0.05)\nRes 728x728: 0.837 (+0.05)\n\nThen using left and right eye information and trained the small neural network on top of it got me:\nPublic score: 0.84613\nPrivate score: 0.83880\n\nIdeas for improving further:\n* Train on the validation data (4000 examples)\n* Larger model (B4,B5,B6,B7?)\n* Larger image resolution\n* Better data augmentations method (Randaugment?)\n* Ensemble for the blending model (fast to train)\n* Ensemble of various CNN models\n* Tweaking hyperparameters\n* Better loss function, better proxy for WeightedKappa\n* ? Comment ideas below",
    "1339533": "Hey @aladdinpersson, really nice video. \nI wanted to know how to load/train with such huge data, like in this case 83GB? I have seen few competitions with more than 50GB of data, how to deal with this?",
    "1345104": "aladdinpersson  Thank you for the great ideas you gave us, I have an extra idea here. Can you show us how we can use  Ben Graham(Competition winner) pre-processing method (specially color version) and train the model from different transfer learning models? I think this way the result will be improved more.",
    "1383942": "How many epochs and how long did it take to train if i may ask?",
    "2142439": "thank you for making video with such detailed explanation"
  },
  "source": "meta"
}