File size: 6,058 Bytes
cbb148a b79798f de61dbf b79798f 33ffeaf b79798f 33ffeaf b79798f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
---
license: apache-2.0
language:
- en
metrics:
- f1
base_model:
- microsoft/resnet-50
- timm/vgg16.tv_in1k
- franklc/InceptionV3_72
pipeline_tag: image-classification
library_name: sklearn
tags:
- Cloud
- Classifier
- YouthAI
- Ensemble
model-index:
- name: Ensemble Learning Cloud Classifier
results:
- task:
type: image-classification
metrics:
- name: f1-score
type: f1-score
value: 0.86
source:
name: Kaggle
url: https://www.kaggle.com/code/momerer/ensemble-learning-cloud-classifier-model-youthai/
---
# Ensemble Learning Cloud Classifier

> **Note:** This project was developed as a 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.
## Overview
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.
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.
## Objectives
- To classify cloud types from images with high accuracy.
- To mitigate the issue of limited training data using **Data Augmentation** and **Transfer Learning**.
- To address class imbalance using **Weighted Loss Functions**.
- To demonstrate the effectiveness of stacking multiple weak(er) learners to create a strong meta-learner.
## Dataset
The dataset consists of **960 images** divided into 7 classes. The data was split into Training (70%), Validation (15%), and Testing (15%) sets.
**Classes:**
1. `cirriform clouds`
2. `clear sky`
3. `cumulonimbus clouds`
4. `cumulus clouds`
5. `high cumuliform clouds`
6. `stratiform clouds`
7. `stratocumulus clouds`
## Model Architecture
The solution uses a **Stacking Ensemble** architecture:
### Level 0: Base Learners
Three pre-trained models (weights from ImageNet) were used as feature extractors. The top layers were removed and replaced with a custom classification head:
1. **ResNet50** (Input: 224x224)
2. **VGG16** (Input: 224x224)
3. **InceptionV3** (Input: 299x299)
**Custom Head Structure:**
- `GlobalAveragePooling2D`
- `Dense(256, activation='relu')` with L2 Regularization (0.01)
- `Dropout(0.6)` (To prevent overfitting)
- `Dense(7, activation='softmax')`
### Level 1: Meta-Learner
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:
- **Input:** Concatenated Predictions
- **Hidden Layer:** Dense(16, relu) + Dropout(0.4)
- **Output:** Final Classification
## Technical Implementation Details
### Data Preprocessing
To handle the small dataset size and prevent overfitting, aggressive **Data Augmentation** was applied during training:
- Rotation range: 40°
- Width/Height shift: 0.25
- Shear/Zoom: 0.25 / 0.3
- Horizontal & Vertical Flips
- Brightness adjustment: [0.7, 1.3]
### Class Balancing
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).
### Hyperparameters
- **Optimizer:** Adam (Learning Rate: 0.0001 for base, 0.001 for meta)
- **Loss Function:** Categorical Crossentropy
- **Batch Size:** 64
- **Epochs:** 75 (with Early Stopping and ReduceLROnPlateau)
## Results
The Ensemble Meta-Model outperformed the individual base models on the test set.
- **Final Accuracy:** 86%
- **F1-Score (Weighted):** 0.85
### Classification Report
Detailed performance metrics by class:
```
precision recall f1-score support
cirriform clouds 0.87 0.95 0.91 21
clear sky 1.00 1.00 1.00 18
cumulonimbus clouds 0.00 0.00 0.00 4
cumulus clouds 0.81 0.94 0.87 32
high cumuliform clouds 0.89 0.86 0.87 36
stratiform clouds 1.00 0.85 0.92 13
stratocumulus clouds 0.70 0.70 0.70 20
accuracy 0.86 144
macro avg 0.75 0.76 0.75 144
weighted avg 0.84 0.86 0.85 144
```
### Performance Visualizations
#### Training vs Validation Accuracy

#### Confusion Matrix

## Installation & Usage
### Prerequisites
```
pip install tensorflow numpy pandas matplotlib seaborn scikit-learn pillow requests
```
### Training
The training pipeline is automated:
1. Load and split data.
2. Calculate class weights.
3. Train ResNet50, VGG16, and InceptionV3 individually.
4. Generate validation predictions from all three models.
5. Train the Meta-Learner on these predictions.
## Credits
- **Author:** Muhammed Ömer ERKOÇ
- **Organization:** Youth AI Initiative
- **Dataset Source:** [SkyVision Cloud Dataset](https://www.kaggle.com/datasets/zeesolver/cloiud-dataset)
_This project is part of the educational curriculum at the Youth AI Initiative, fostering the next generation of AI specialists._ |