Train and Serve a Weather Prediction Model
Use the weather data your Project 1 pipeline collected to train a model that predicts tomorrow's temperature — with honest baselines, leakage-free features, real evaluation, and a live FastAPI endpoint.
In Project 1 you built the pipeline. Now you do what ML engineers do with pipeline data: turn it into a model that makes a prediction, prove the prediction is actually worth something, and put it behind an API that anything can call.
SQLite (Project 1) → features.py → time-aware train/test → train.py → model.joblib → serve.py (FastAPI) → GET /predict
What you'll build
A model that predicts tomorrow's mean temperature for your three cities, trained on the data your own pipeline collected. You'll engineer time-series features without leaking the future, beat a "dumb" persistence baseline (the bar every real model must clear), save the winner with joblib, and serve it from a FastAPI /predict endpoint you can hit with curl.
How this works
Work through the steps in order. Lessons teach the concept. Quizzes check you got it. Milestones are where you build — you'll paste your code and output, and your AI mentor reviews it like a senior engineer would in a pull request: what's good, what's wrong, and hints (never the answer).
Prerequisites
Project 1 (Build a Weather Data Pipeline) — you need its SQLite database and its code. If you've only run the pipeline for a few days, no problem: step 1 shows you how to backfill ~3 months of history with one parameter change (past_days=92). You should be comfortable with pandas basics from Project 1; scikit-learn and FastAPI are introduced when you need them.
What you'll learn
- Engineer leakage-free time-series features with lags and rolling windows
- Split time-series data correctly and explain why random shuffles lie
- Beat a persistence baseline with scikit-learn and prove it with MAE/RMSE
- Package a trained model with joblib and serve live predictions over HTTP
Steps
- 1. From pipeline to prediction
- 2. Features, lags, and the leakage trap
- 3. Quiz: features & leakage
- 4. Milestone: build features.pyAI review
- 5. Baseline first, model second
- 6. Quiz: baselines & metrics
- 7. Milestone: build train.pyAI review
- 8. From .joblib file to live API
- 9. Quiz: serving models
- 10. Milestone: build serve.pyAI review
- 11. Wrap-up: make it portfolio-ready