Update README.md
Browse files
README.md
CHANGED
|
@@ -27,4 +27,189 @@ model-index:
|
|
| 27 |
source:
|
| 28 |
name: Kaggle
|
| 29 |
url: https://www.kaggle.com/code/momerer/ensemble-learning-cloud-classifier-model-youthai/
|
| 30 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
source:
|
| 28 |
name: Kaggle
|
| 29 |
url: https://www.kaggle.com/code/momerer/ensemble-learning-cloud-classifier-model-youthai/
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
# Ensemble Learning Cloud Classifier
|
| 36 |
+

|
| 37 |
+
|
| 38 |
+
> **Note:** This project was developed as a capstone assignment for the **Youth AI Initiative**. It demonstrates the application of advanced Deep Learning techniques (Transfer Learning and Stacking Ensembles) to solve meteorological classification problems.
|
| 39 |
+
|
| 40 |
+
## Overview
|
| 41 |
+
|
| 42 |
+
This project implements a robust **Ensemble Learning** model to classify images of clouds into 7 distinct meteorological categories. By leveraging the power of **Transfer Learning**, we combine three state-of-the-art Convolutional Neural Networks (ResNet50, VGG16, and InceptionV3) to extract features, which are then fed into a Meta-Learner (Neural Network) to make the final prediction.
|
| 43 |
+
|
| 44 |
+
This "Stacked Generalization" approach achieves higher accuracy and stability compared to using individual models alone, effectively handling the visual complexity and ambiguity often found in cloud formations.
|
| 45 |
+
|
| 46 |
+
## Objectives
|
| 47 |
+
|
| 48 |
+
- To classify cloud types from images with high accuracy.
|
| 49 |
+
|
| 50 |
+
- To mitigate the issue of limited training data using **Data Augmentation** and **Transfer Learning**.
|
| 51 |
+
|
| 52 |
+
- To address class imbalance using **Weighted Loss Functions**.
|
| 53 |
+
|
| 54 |
+
- To demonstrate the effectiveness of stacking multiple weak(er) learners to create a strong meta-learner.
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
## Dataset
|
| 58 |
+
|
| 59 |
+
The dataset consists of **960 images** divided into 7 classes. The data was split into Training (70%), Validation (15%), and Testing (15%) sets.
|
| 60 |
+
|
| 61 |
+
**Classes:**
|
| 62 |
+
|
| 63 |
+
1. `cirriform clouds`
|
| 64 |
+
|
| 65 |
+
2. `clear sky`
|
| 66 |
+
|
| 67 |
+
3. `cumulonimbus clouds`
|
| 68 |
+
|
| 69 |
+
4. `cumulus clouds`
|
| 70 |
+
|
| 71 |
+
5. `high cumuliform clouds`
|
| 72 |
+
|
| 73 |
+
6. `stratiform clouds`
|
| 74 |
+
|
| 75 |
+
7. `stratocumulus clouds`
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
## Model Architecture
|
| 79 |
+
|
| 80 |
+
The solution uses a **Stacking Ensemble** architecture:
|
| 81 |
+
|
| 82 |
+
### Level 0: Base Learners
|
| 83 |
+
|
| 84 |
+
Three pre-trained models (weights from ImageNet) were used as feature extractors. The top layers were removed and replaced with a custom classification head:
|
| 85 |
+
|
| 86 |
+
1. **ResNet50** (Input: 224x224)
|
| 87 |
+
|
| 88 |
+
2. **VGG16** (Input: 224x224)
|
| 89 |
+
|
| 90 |
+
3. **InceptionV3** (Input: 299x299)
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
**Custom Head Structure:**
|
| 94 |
+
|
| 95 |
+
- `GlobalAveragePooling2D`
|
| 96 |
+
|
| 97 |
+
- `Dense(256, activation='relu')` with L2 Regularization (0.01)
|
| 98 |
+
|
| 99 |
+
- `Dropout(0.6)` (To prevent overfitting)
|
| 100 |
+
|
| 101 |
+
- `Dense(7, activation='softmax')`
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
### Level 1: Meta-Learner
|
| 105 |
+
|
| 106 |
+
The predictions (probability vectors) from the three base models are concatenated to form a meta-input vector (size 21). This is fed into a dense neural network:
|
| 107 |
+
|
| 108 |
+
- **Input:** Concatenated Predictions
|
| 109 |
+
|
| 110 |
+
- **Hidden Layer:** Dense(16, relu) + Dropout(0.4)
|
| 111 |
+
|
| 112 |
+
- **Output:** Final Classification
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
## Technical Implementation Details
|
| 116 |
+
|
| 117 |
+
### Data Preprocessing
|
| 118 |
+
|
| 119 |
+
To handle the small dataset size and prevent overfitting, aggressive **Data Augmentation** was applied during training:
|
| 120 |
+
|
| 121 |
+
- Rotation range: 40°
|
| 122 |
+
|
| 123 |
+
- Width/Height shift: 0.25
|
| 124 |
+
|
| 125 |
+
- Shear/Zoom: 0.25 / 0.3
|
| 126 |
+
|
| 127 |
+
- Horizontal & Vertical Flips
|
| 128 |
+
|
| 129 |
+
- Brightness adjustment: [0.7, 1.3]
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
### Class Balancing
|
| 133 |
+
|
| 134 |
+
Class weights were computed using `sklearn.utils.class_weight` to penalize the model more for misclassifying rare classes (e.g., _Cumulonimbus_ which had a weight of ~5.33).
|
| 135 |
+
|
| 136 |
+
### Hyperparameters
|
| 137 |
+
|
| 138 |
+
- **Optimizer:** Adam (Learning Rate: 0.0001 for base, 0.001 for meta)
|
| 139 |
+
|
| 140 |
+
- **Loss Function:** Categorical Crossentropy
|
| 141 |
+
|
| 142 |
+
- **Batch Size:** 64
|
| 143 |
+
|
| 144 |
+
- **Epochs:** 75 (with Early Stopping and ReduceLROnPlateau)
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
## Results
|
| 148 |
+
|
| 149 |
+
The Ensemble Meta-Model outperformed the individual base models on the test set.
|
| 150 |
+
|
| 151 |
+
- **Final Accuracy:** 86%
|
| 152 |
+
|
| 153 |
+
- **F1-Score (Weighted):** 0.85
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
### Classification Report
|
| 157 |
+
|
| 158 |
+
Detailed performance metrics by class:
|
| 159 |
+
|
| 160 |
+
```
|
| 161 |
+
precision recall f1-score support
|
| 162 |
+
|
| 163 |
+
cirriform clouds 0.87 0.95 0.91 21
|
| 164 |
+
clear sky 1.00 1.00 1.00 18
|
| 165 |
+
cumulonimbus clouds 0.00 0.00 0.00 4
|
| 166 |
+
cumulus clouds 0.81 0.94 0.87 32
|
| 167 |
+
high cumuliform clouds 0.89 0.86 0.87 36
|
| 168 |
+
stratiform clouds 1.00 0.85 0.92 13
|
| 169 |
+
stratocumulus clouds 0.70 0.70 0.70 20
|
| 170 |
+
|
| 171 |
+
accuracy 0.86 144
|
| 172 |
+
macro avg 0.75 0.76 0.75 144
|
| 173 |
+
weighted avg 0.84 0.86 0.85 144
|
| 174 |
+
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
### Performance Visualizations
|
| 178 |
+
|
| 179 |
+
#### Training vs Validation Accuracy
|
| 180 |
+
|
| 181 |
+

|
| 182 |
+
|
| 183 |
+
#### Confusion Matrix
|
| 184 |
+

|
| 185 |
+
|
| 186 |
+
## Installation & Usage
|
| 187 |
+
|
| 188 |
+
### Prerequisites
|
| 189 |
+
|
| 190 |
+
```
|
| 191 |
+
pip install tensorflow numpy pandas matplotlib seaborn scikit-learn pillow requests
|
| 192 |
+
|
| 193 |
+
```
|
| 194 |
+
|
| 195 |
+
### Training
|
| 196 |
+
|
| 197 |
+
The training pipeline is automated:
|
| 198 |
+
|
| 199 |
+
1. Load and split data.
|
| 200 |
+
2. Calculate class weights.
|
| 201 |
+
3. Train ResNet50, VGG16, and InceptionV3 individually.
|
| 202 |
+
4. Generate validation predictions from all three models.
|
| 203 |
+
5. Train the Meta-Learner on these predictions.
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
## Credits
|
| 207 |
+
|
| 208 |
+
- **Author:** Muhammed Ömer ERKOÇ
|
| 209 |
+
|
| 210 |
+
- **Organization:** Youth AI Initiative
|
| 211 |
+
|
| 212 |
+
- **Dataset Source:** [SkyVision Cloud Dataset](https://www.kaggle.com/datasets/zeesolver/cloiud-dataset)
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
_This project is part of the educational curriculum at the Youth AI Initiative, fostering the next generation of AI specialists._
|