Hybrid CNN-LSTM neural network predicting temperature in Algiers from multivariate climate data.
# CNN-LSTM Temperature Forecasting
Undergraduate final project done for a Bachelor's degree in Operational Research.
Accurate temperature forecasting has practical applications across energy planning, agriculture, and urban infrastructure. This project builds a hybrid CNN-LSTM model to forecast daily temperature in Algiers from multivariate climate data, achieving 1.94°C RMSE on an unseen test set. The model is lightweight (90K parameters), making it suitable for resource-constrained environments.
**Key Features:**
- Combines CNN for local pattern extraction with LSTM for temporal dependency modeling
- Multivariate approach using 5 climate variables
- 8 years of historical weather data (2016-2024)
- Achieves **1.94°C RMSE** on unseen test set
## Results
### Performance Metrics
| Metric | Value |
|--------|-------|
| **RMSE (Test)** | 1.94°C |
| **MAE (Test)** | ~1.26°C |
| **Relative Error** | 6.3% |
| **Parameters** | 90,945 |
### Model Comparison
Comparison of RMSE across different CNN-LSTM architectures
### Predictions vs Actual Temperature
Time series comparison showing excellent tracking of seasonal patterns
### Prediction Accuracy
Scatter plot demonstrating strong correlation between predictions and actual values
## Model Architecture
```
Input Shape: (timesteps, 5 features)
↓
Conv1D(256 filters, kernel=3, activation=relu)
↓
MaxPooling1D(pool_size=2)
↓
LSTM(64 units)
↓
Dense(32 units, activation=relu)
↓
Dense(1 unit, activation=linear)
↓
Output: Temperature (°C)
```
**Summary:**
- **Total Parameters:** 90,945
- **Trainable Parameters:** 90,945
- **Optimizer:** Adam
- **Loss Function:** Mean Squared Error (MSE)
## Dataset
### Overview
- **Location:** Algiers, Algeria
- **Period:** June 2016 - April 2024 (8 years)
- **Frequency:** Daily observations
- **Source:** rp5.ru Weather Archives)
### Features (Input Variables)
| Variable | Description | Unit |
|----------|-------------|------|
| Temperature | Air temperature | °C |
| Pressu …