Better Forecast: an 8-week AI lab project
Three weather forecasts for tomorrow almost never agree. Which one should you believe?
In this project you build a small web application that learns from past days how to combine several forecasts into one better forecast, for Budapest and Eger.
Live demo of the finished project: https://caiweather.vedara.net
What you build
forecast sources your program your web page
┌───────────────┐ ┌──────────────────────┐ ┌────────────────────────┐
│ Open-Meteo │──┐ │ collect.py (daily) │ │ chart: forecasts vs. │
│ MET Norway │──┼──▶ │ ↓ │ │ measured │
│ wttr.in │──┘ │ weather.db (SQLite) │──▶ Flask ─▶│ error of each source │
│ + 3 weather │ │ ↓ │ │ OUR best forecast for │
│ models with │ │ ml.py: regressors + │ │ tomorrow │
│ 2.5 years │ │ neural net, combined │ │ │
│ of history │ └──────────────────────┘ └────────────────────────┘
└───────────────┘
Two data sets:
| Set | Sources | Where it comes from | Size |
|---|---|---|---|
history (models) |
ECMWF, GFS, ICON weather models | downloaded once: real day-ahead forecasts since Feb 2024 | ~970 days |
live (providers) |
Open-Meteo, MET Norway, wttr.in | you collect it every morning from week 2 | grows by 1 day/day |
What are ECMWF, GFS and ICON? They are the three best-known global weather models: big physics simulations of the atmosphere that weather services run several times a day. ECMWF (IFS) is run by the European Centre for Medium-Range Weather Forecasts and is usually the most accurate; GFS (Global Forecast System) by NOAA, the US weather service; ICON by DWD, the German weather service. The providers in the live set take outputs like these and process them further.
The big history set is used to learn and test the machine learning (weeks 5–7). In week 8 you run the same code on your own live data and compare.
Plan
| Week | Topic | Result at the end of the week |
|---|---|---|
| 1 | Installation + getting data from the internet | Python and packages installed; a script prints tomorrow's forecast from 3 providers for both cities |
| 2 | Saving data + daily automatic collection | weather.db, Windows Task Scheduler runs collect.py every morning |
| 3 | Past data, measured values, data checking | ~970 days of history in the database, a data quality report |
| 4 | Web app with Flask | A page with a chart, an error table and the latest days |
| 5 | First regressors | Linear regression and random forest beat the single forecasts |
| 6 | Neural network | An MLP neural net, compared with week 5 |
| 7 | Combining the models | A combined model, "Train" button, "our best forecast" on the page |
| 8 | Automation, live evaluation, tests | Daily retrain + forecast, live score, tests, final presentation |
How every week works
- Goal: what you will have at the end.
- Ideas: the few new things you need to understand, explained simply.
- Steps: what to type, with the complete code.
- Check: how you know it works.
- Extra: a small task for those who finish early.
If you fall behind, download the finished code of the previous week (links below) and continue from there.
Your own weather.db is not in the downloads, so keep your project folder: the data you collect is valuable.
Downloads
| Week | Code at the end of the week |
|---|---|
| 1 | week01.zip |
| 2 | week02.zip |
| 3 | week03.zip |
| 4 | week04.zip |
| 5 | week05.zip |
| 6 | week06.zip |
| 7 | week07.zip |
| 8 | week08.zip |
Everything in one file: all_weeks.zip
Class database: the demo server collects data every morning. If your own collection has gaps, you can use its database: weather.db (updated daily at 08:00).