This project predicts temperature, humidity, and pressure using historical weather data from European cities (2000-2010) through linear regression modeling. Developed in Jupyter Notebook for the Artificial Intelligence course.
Predicts three key meteorological variables for Basel:
- Temperature (°C)
- Humidity (stored as a fraction in the raw data; reported as %)
- Pressure (stored in bar in the raw data; reported as hPa)
Using machine learning (Linear Regression) on a dataset covering 18 European cities.
'Affan Najiy Bin Rusdi
Student ID: 22010453
University: Universiti Teknologi PETRONAS
Source: Zenodo Weather Prediction Dataset
Features:
- Daily meteorological records (2000-2010)
- 18 European cities
- Multiple weather parameters
- Python 3
- Libraries:
- pandas (data handling)
- numpy (numerical operations)
- matplotlib/seaborn (visualization)
- scikit-learn (machine learning)
Data Preprocessing
- Physical plausibility check — rejects impossible sensor readings (e.g. negative air pressure) that
dropna()cannot catch - Missing value handling
- Drop raw DATE column (kept MONTH for seasonal signal)
- Correlation analysis
Modeling
- Separate Linear Regression models for temperature, humidity and pressure
- Chronological 80/20 split (train 2000–2008, test 2008–2010) — avoids letting the model learn from the future to predict the past
- No target leakage: each model is blind to the other two targets for the same day
- Two framings compared: same-day estimation vs. genuine next-day forecasting
Evaluation Metrics
- Mean Absolute Error (MAE), reported in real units (°C, %, hPa)
- Mean Squared Error (MSE)
- R² Score
- Compared against two baselines: seasonal average, and persistence ("tomorrow = today")
- Four corrupted rows out of 3,654 (negative and near-vacuum pressure readings) were enough to push several models to negative R², i.e. worse than guessing the average. Removing them lifted next-day pressure R² from −9.24 to 0.82.
- Same-day estimation is near-perfect (temperature R² 0.996, off by 0.38 °C) because regional weather moves as one system — but this is reconstruction, not forecasting.
- Genuine next-day forecasting is far harder: temperature error more than triples to 1.30 °C, though it still beats persistence by 21%.
- Humidity is consistently the hardest target, being driven by local effects rather than regional patterns.
1. Data Loading & Inspection
2. Missing Value Analysis
3. Data Cleaning (incl. physical plausibility check)
4. Feature Selection
5. Chronological Train-Test Split
6. Model Training
7. Evaluation (MAE / MSE / R²)
8. Visualisation
9. Baseline Comparison
10. Next-Day Forecasting
11. Feature Influence Analysis
12. Error Breakdown by Month
13. Conclusions
A plain-language walkthrough of the whole analysis is published via GitHub Pages, rebuilt automatically from the notebook on every push.
Install requirements:
pip install pandas numpy matplotlib seaborn scikit-learn
Run Jupyter Notebook:
jupyter notebook weather_predict.ipynb
- MSE: Measures average squared difference between predicted and actual values
- R² Score: Indicates proportion of variance explained by the model
- Correlation: Statistical relationship between variables (-1 to 1)
Educational use only - Not for commercial purposes
- Huber, F. (2021, May 18). Weather prediction dataset. Retrieved from Zenodo: https://zenodo.org/records/4770937