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
| Metric | Value |
|---|---|
| RMSE (Test) | 1.94°C |
| MAE (Test) | ~1.26°C |
| Relative Error | 6.3% |
| Parameters | 90,945 |
Comparison of RMSE across different CNN-LSTM architectures
Time series comparison showing excellent tracking of seasonal patterns
Scatter plot demonstrating strong correlation between predictions and actual values
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)
- Location: Algiers, Algeria
- Period: June 2016 - April 2024 (8 years)
- Frequency: Daily observations
- Source: rp5.ru Weather Archives
| Variable | Description | Unit |
|---|---|---|
| Temperature | Air temperature | °C |
| Pressure | Atmospheric pressure | hPa |
| Humidity | Relative humidity | % |
| Wind Speed | Average wind speed | m/s |
| Dew Point | Dew point temperature | °C |
- Training: 80% (2016-2022)
- Validation: 10% (2023)
- Test: 10% (2024)
| Set | Min (°C) | Max (°C) | Range (°C) |
|---|---|---|---|
| Actual | 8.44 | 39.96 | 31.52 |
| Predicted | 7.85 | 32.25 | 24.40 |
- Normalization using MinMaxScaler (0-1 range)
- Sliding window approach for sequence creation
- Handling missing values and outliers
- Epochs: 50 with Early Stopping (patience=10)
- Batch Size: 32
- Validation Strategy: Temporal split to prevent data leakage
- Callbacks: ModelCheckpoint, EarlyStopping
- RMSE (Root Mean Squared Error)
- MAE (Mean Absolute Error)
- Visual analysis of predictions vs actual values
- Excellent Accuracy: RMSE of 1.94°C is comparable to operational weather models
- Captures Seasonality: Successfully tracks seasonal temperature variations
- Lightweight and efficient model Only 90K parameters, suitable for resource-constrained environments
- Multivariate Approach: Leverages multiple climate variables for robust predictions
- No Overfitting: Validation and test performance are consistent
- Extreme Temperature Underestimation: Model predicts max 32.25°C vs actual 39.96°C
- Extrapolation Challenge
The test set (2024) contains unprecedented heat records not present in the training data (2016–2022), which explains the underestimation. This is a known limitation of neural networks when extrapolating beyond their training distribution. Proposed mitigations include a weighted loss function to penalize extreme temperature errors more heavily, and synthetic augmentation of extreme samples.
Potential enhancements to consider:
- Weighted Loss Function: Penalize errors on extreme temperatures more heavily
- Data Augmentation: Synthesize additional extreme temperature samples
- Cyclical Features: Encode seasonal patterns (month, day of year)
- Multi-step Forecasting: Predict temperature for next 7-14 days
- Transfer Learning: Adapt model to other geographic locations