Django web app that serves a SARIMAX + Fourier-seasonality temperature forecast for Alexandria, Egypt — pick a date, get a prediction with a 95% CI.
# Alexandria Weather Forecast — Django App (Task 6)
A Django web app that wraps the SARIMAX temperature-forecasting model from
**Task 5** (`weather_forecasting_sarima.ipynb`) so a user can pick a date and
instantly get a predicted daily mean temperature for Alexandria, Egypt, with a
95% confidence interval.
| | |
|---|---|
| Form | |
| Result | |
| Validation error | |
## What's here
```
weather_predictor/
├── manage.py
├── requirements.txt
├── weather_project/ # Django project settings/urls
├── predictor/ # The forecasting app
│ ├── forms.py # Date input + validation
│ ├── views.py # Form view + JSON API + caching
│ ├── model_loader.py # Loads the pickled SARIMAX model once, builds
│ │ # future Fourier exog, runs get_forecast()
│ ├── ml/train_model.py # Reproduces the Task 5 pipeline end-to-end
│ │ # and saves model/sarimax_model.pkl
│ ├── templates/predictor/ # Bootstrap 5 templates
│ └── static/predictor/css/ # Custom styling on top of Bootstrap
├── model/
│ ├── sarimax_model.pkl # Trained model (statsmodels SARIMAXResults)
│ └── model_metadata.json # order, Fourier settings, training date range
├── data/weather_raw.json # Offline data cache (see note below)
└── screenshots/
```
## About the bundled model
`data/weather_raw.json` is the real NASA POWER pull from Task 5 — daily
temperature, precipitation, humidity, and wind speed for Alexandria, Egypt,
2021-01-01 through 2025-12-31. `model/sarimax_model.pkl` was trained directly
on this data by `predictor/ml/train_model.py`, refitting the notebook's
`SARIMAX(1,1,2)` + annual Fourier terms spec on the full history so the app's
forecasts start from the most recent real observation (2025-12-31).
`predictor/ml/train_model.py` tries the live NASA POWER API first and only
falls back to this cached file if the request fails (e.g. no network access),
exactly like Task 5's …