momererkoc commited on
Commit
b79798f
·
verified ·
1 Parent(s): cbb148a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +186 -1
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
+ ![YouthAI Initiative](https://youthaiinitiative.com/wp-content/uploads/2023/09/Adsiz-2100-x-2970-piksel-scaled-e1759947420412-1024x541.png)
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
+ ![Train/Val Acc](https://www.kaggleusercontent.com/kf/280733528/eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..w10CR0iyNAplIYsVSY1hoQ.d1w4RF3N7X0cuybdfDu_F4MyMcaUKRqyNb6i6NXM_eh6KbU8Xfp1wcJEgBs9QkU5UDsyCU2Bm7dj3ap3rRB8eLHGcrdpza-gakim7P_Szcj9V2tiU8sWEW5niEltG4S9BPiDBqVBtKzunbYBhSua6j5-OibvthpoEggxQAszOdHgR2MBFb_8r0WXTgrn-g9bPQtRbUVOyS1dj_xdXdvq1U6TnIYtiavLBySamAv6fVipPcfMfe3MHmeg4RJRyceaPyM9o7d_6QAC4Ta0EBxcu0qXYgiBI7ve_0bJNskxB1oVxVkKoOqwaFEige9xS1ybl3jgjy8Tog7jGz7JiaDysYOMIpaJwgo3vWn_PHjtLkRac_d5l1zNXErl02eeA7TakIG8tffXHVzKLH6vIQcLkjLswCl6xq5tYWzaAV_XIMZgkIYdwyDuy_j5BCIzYbdOCMhWxpeY26WB_NJkGOEZ4gYuyywgwYij8mqU3yP6nWSgES7k2TUr_YRTSlcQG-pwHtjG4az-rBaVYYl8vrLGJIXcQahHKq5_tQIrGJOD8SWWBKPcKo7nlcEa1xA5FPbR8vZscd7all_-oINspprqbLcCjy151T8GHrJkLlpZpr1ZLFKmtgXKZPanGc9UTN6zVBu1RlgkJNcDgHTOvRAUbfodr8x71xKsvVbX0ndmOTM.8eAEKrO9BxZmtjpkUPwo0A/__results___files/__results___13_0.png)
182
+
183
+ #### Confusion Matrix
184
+ ![Conf Matrix](https://www.kaggleusercontent.com/kf/280733528/eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..w10CR0iyNAplIYsVSY1hoQ.d1w4RF3N7X0cuybdfDu_F4MyMcaUKRqyNb6i6NXM_eh6KbU8Xfp1wcJEgBs9QkU5UDsyCU2Bm7dj3ap3rRB8eLHGcrdpza-gakim7P_Szcj9V2tiU8sWEW5niEltG4S9BPiDBqVBtKzunbYBhSua6j5-OibvthpoEggxQAszOdHgR2MBFb_8r0WXTgrn-g9bPQtRbUVOyS1dj_xdXdvq1U6TnIYtiavLBySamAv6fVipPcfMfe3MHmeg4RJRyceaPyM9o7d_6QAC4Ta0EBxcu0qXYgiBI7ve_0bJNskxB1oVxVkKoOqwaFEige9xS1ybl3jgjy8Tog7jGz7JiaDysYOMIpaJwgo3vWn_PHjtLkRac_d5l1zNXErl02eeA7TakIG8tffXHVzKLH6vIQcLkjLswCl6xq5tYWzaAV_XIMZgkIYdwyDuy_j5BCIzYbdOCMhWxpeY26WB_NJkGOEZ4gYuyywgwYij8mqU3yP6nWSgES7k2TUr_YRTSlcQG-pwHtjG4az-rBaVYYl8vrLGJIXcQahHKq5_tQIrGJOD8SWWBKPcKo7nlcEa1xA5FPbR8vZscd7all_-oINspprqbLcCjy151T8GHrJkLlpZpr1ZLFKmtgXKZPanGc9UTN6zVBu1RlgkJNcDgHTOvRAUbfodr8x71xKsvVbX0ndmOTM.8eAEKrO9BxZmtjpkUPwo0A/__results___files/__results___13_2.png)
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._