|
| 1 | +# Hyper-Parameter Tuning Techniques for Brain Tumor MRI Classification |
| 2 | + |
| 3 | +The dataset on which the cross validation is carried out can be found [on kaggle](https://www.kaggle.com/datasets/theiturhs/brain-tumor-mri-classification-dataset/data). Find the implementation of this in Hyper-parameter_Tuning.ipynb notebook. Learner module, FastAI, is considered to provide a convenient way to create and fine-tune convolutional neural network (CNN) models. vision.learner is a function that helps us to construct a learner object, which has the model architecture, data, training configuration, and other elements. We can specify a pre-trained model architecture and fine-tune it on the dataset. |
| 4 | + |
| 5 | +### Hyper-Parameter Tuning Teachniques carried out are as follows: |
| 6 | +*Different techniques to find out suitable hyper-parameters* |
| 7 | +* Random Search optimization algorithm |
| 8 | +* Hyperparameter Optimization with Optuna's Successive Halving Pruner |
| 9 | + |
| 10 | +### Different techniques and their obtained training accuracies¶ |
| 11 | +| Technique | Accuracy Score | Architecture | Weight Decay | Epochs | Batch Size | Drop | |
| 12 | +| -- | -- | -- | -- | -- | -- | -- | |
| 13 | +| Random Search optimization algorithm - Run 1 | 95.27% | ResNet50 | 5.527e-5 | 7 | 64 | 0.4 | |
| 14 | +| Random Search optimization algorithm - Run 2 | 95.53% | ResNet50 | 4e-6 | 5 | 64 | 0.2 | |
| 15 | +| Hyperparameter Optimization with Optuna's Successive Halving Pruner | 98.51% | ResNet18 | 0.004016 | 13 | 32 | 0.2680 | |
| 16 | + |
| 17 | +**Out of these techniques,Hyperparameter Optimization with Optuna's Successive Halving Pruner technique gives better overall accuracy. It almost take 40-50 minutes for each to fine-tune the model.** |
| 18 | + |
| 19 | +NOTE: Since here we need to find the best technique that we can use for hyper-parameter tuning of our dataset, and it takes almost 40-50 minutes on an average to get results from each techniques (where we have only considered training dataset not augmented data), thus RandomSplitting is implemented to divide the dataset. |
| 20 | + |
| 21 | +#### Random Search Optimizing Algorithm - Run 1 |
| 22 | + |
| 23 | +For n_trails = 10, the accuracy score and best hyper-parameter are as follows: |
| 24 | + |
| 25 | +| Trail No. | Best Score | Architecture | Weight Decay | Epochs | Batch Size | Drop | |
| 26 | +|-----------|------------|--------------|--------------|--------|------------|------| |
| 27 | +| 0 | 0.9011 | ResNet34 | 0.00024 | 8 | 64 | 0.4 | |
| 28 | +| 1 | 0.9413 | ResNet18 | 0.0090 | 15 | 64 | 0.2 | |
| 29 | +| 2 | 0.9343 | ResNet18 | 0.0065 | 5 | 32 | 0.4 | |
| 30 | +| 3 | 0.9080 | ResNet34 | 0.00062 | 5 | 32 | 0.4 | |
| 31 | +| 4 | 0.9019 | ResNet34 | 0.00092 | 6 | 64 | 0.2 | |
| 32 | +| **5** | **0.9527** | **ResNet50** | **0.00005** | **7** | **64** | **0.4** | |
| 33 | +| 6 | 0.9220 | ResNet34 | 0.00895 | 15 | 64 | 0.2 | |
| 34 | +| 7 | 0.9404 | ResNet18 | 0.0035 | 11 | 64 | 0.4 | |
| 35 | +| 8 | 0.9212 | ResNet18 | 0.0002 | 5 | 64 | 0.4 | |
| 36 | +| 9 | 0.9203 | ResNet34 | 0.0007 | 13 | 32 | 0.4 | |
| 37 | + |
| 38 | +The best accuracy score is 0.9527 with these hyperparameters: |
| 39 | + |
| 40 | +- Architecture: ResNet 50 |
| 41 | +- Weight Decay: 5.527e-5 |
| 42 | +- Epochs: 7 |
| 43 | +- Batch Size: 64 |
| 44 | +- Drop: 0.4 |
| 45 | + |
| 46 | +#### Random Search Optimizing Algorithm - Run 2 |
| 47 | + |
| 48 | +For n_trails = 10, the accuracy score and best hyper-parameter are as follows: |
| 49 | + |
| 50 | +| Trial | Best Score | Architecture | Weight Decay | Epochs | Batch Size | Drop | |
| 51 | +|-------|------------|--------------|--------------|--------|------------|------| |
| 52 | +| 0 | 0.9177 | ResNet34 | 0.000248 | 6 | 32 | 0.2 | |
| 53 | +| 1 | 0.9492 | ResNet50 | 0.002137 | 7 | 64 | 0.4 | |
| 54 | +| 2 | 0.9518 | ResNet50 | 0.000004 | 8 | 64 | 0.2 | |
| 55 | +| 3 | 0.9046 | ResNet34 | 0.000269 | 6 | 64 | 0.2 | |
| 56 | +| 4 | 0.9378 | ResNet50 | 0.000058 | 6 | 32 | 0.2 | |
| 57 | +| 5 | 0.9352 | ResNet18 | 0.000154 | 7 | 32 | 0.2 | |
| 58 | +| 6 | 0.9063 | ResNet34 | 0.000006 | 5 | 64 | 0.4 | |
| 59 | +| **7** | **0.9553** | **ResNet50** | **0.000004** | **13** | **64** | **0.2** | |
| 60 | +| 8 | 0.9238 | ResNet34 | 0.000824 | 13 | 64 | 0.4 | |
| 61 | +| 9 | 0.9361 | ResNet18 | 0.000018 | 8 | 32 | 0.2 | |
| 62 | + |
| 63 | +The best accuracy score is 0.9553 with these hyperparameters: |
| 64 | + |
| 65 | +- Architecture: ResNet 50 |
| 66 | +- Weight Decay: 4e-6 |
| 67 | +- Epochs: 5 |
| 68 | +- Batch Size: 64 |
| 69 | +- Drop: 0.2 |
| 70 | + |
| 71 | +#### Hyperparameter Optimization with Optuna's Successive Halving Pruner |
| 72 | + |
| 73 | +For n_trails = 10, accuracy scores and hyper-paramters are: |
| 74 | + |
| 75 | +| Trial | Best Score | Architecture | Weight Decay | Epochs | Batch Size | Drop | |
| 76 | +|-------|------------|--------------|--------------|--------|------------|--------------------| |
| 77 | +| 0 | 0.9623 | resnet50 | 2.057e-06 | 8 | 32 | 0.2888 | |
| 78 | +| 1 | 0.9518 | resnet50 | 0.001421 | 7 | 32 | 0.2707 | |
| 79 | +| 2 | 0.9807 | resnet34 | 3.744e-06 | 9 | 32 | 0.3918 | |
| 80 | +| 3 | 0.9641 | resnet18 | 2.667e-05 | 7 | 64 | 0.3196 | |
| 81 | +| 4 | 0.9711 | resnet34 | 0.005883 | 8 | 64 | 0.2000 | |
| 82 | +| 5 | 0.9650 | resnet18 | 5.694e-06 | 6 | 64 | 0.2266 | |
| 83 | +| 6 | 0.9737 | resnet18 | 1.813e-05 | 6 | 64 | 0.3732 | |
| 84 | +| **7** | **0.9851** | **resnet34** | **0.004016** | **13** | **32** | **0.2680** | |
| 85 | +| 8 | 0.9667 | resnet50 | 0.008095 | 15 | 32 | 0.3013 | |
| 86 | +| 9 | 0.9632 | resnet50 | 0.0006995 | 6 | 32 | 0.3595 | |
| 87 | + |
| 88 | +The best accuracy score is 0.9851 with these hyperparameters: |
| 89 | + |
| 90 | +- Architecture: ResNet 34 |
| 91 | +- Weight Decay: 0.004016 |
| 92 | +- Epochs: 13 |
| 93 | +- Batch Size: 32 |
| 94 | +- Drop: 0.268 |
| 95 | + |
| 96 | +##### Summarizing |
| 97 | + |
| 98 | +1. Random search optimization gives almost 95% accuracy when we ran it two times each with 10 iterations. |
| 99 | +2. Hyperparameter Optimization with Optuna's Successive Halving Pruner, we are getting 98.51% which is a remarkable accuracy. |
| 100 | + |
| 101 | +**So we will be using k-fold validation technique followed by Hyperparameter Optimization with Optuna's Successive Halving Pruner for getting the appropriate hyper-parameters.** |
0 commit comments