Context: Build a spatial risk assessment system correlating air quality data with children's respiratory disease incidence across Wuhan. Approach: FastAPI backend serving PostGIS spatial queries, React frontend with Deck.gl maps, and a PyTorch SpatialTemporalGCN pipeline for multi-day (1d/3d/7d) risk prediction. Changes: - backend/ — FastAPI API with auth (JWT), alerts, risk analysis, geocoded case data, grid statistics, and report endpoints - frontend/ — React dashboard with interactive risk maps, alert monitoring, district comparison charts, and timeline player - models/ — SpatialTemporalGCN model with trained weights and ONNX export for inference - scripts/ — ETL pipeline for weather + medical data, grid generation, feature engineering, training, and daily inference - deploy/ — Docker Compose configs for backend, frontend, and MLflow - docs/ — API docs, deployment guide, user guide, and code review Impact: Enables spatial risk visualization, alert monitoring, and ML-driven health risk forecasting for environmental health teams.
40 lines
1.2 KiB
Markdown
40 lines
1.2 KiB
Markdown
# Models — SpatialTemporalGCN
|
|
|
|
## Architecture
|
|
|
|
Spatiotemporal GCN for Wuhan respiratory disease risk prediction:
|
|
|
|
- **Temporal**: Transformer encoder (3 layers, 4 heads) over 14-day weather windows
|
|
- **Spatial**: 2-layer GCN (48→128→64) with elevation/population scaling
|
|
- **Output**: `[N, 3]` risk probabilities (1-day, 3-day, 7-day horizons)
|
|
|
|
## Files
|
|
|
|
```
|
|
models/spatiotemporal_gcn/
|
|
model.py # SpatialTemporalGCN class + ONNX export
|
|
sampler.py # Graph sampling utilities
|
|
best_model.pt # Trained weights (gitignored)
|
|
```
|
|
|
|
## Input Shape
|
|
|
|
- Node features: `[N, T=14, 48]` — N nodes, 14 timesteps, 48 weather features
|
|
- Edge index: `[2, E]` — sparse adjacency from 100m grid graph
|
|
- Spatial scalars: elevation + population density per node
|
|
|
|
## Training
|
|
|
|
```bash
|
|
python scripts/train_model.py # Full pipeline with MLflow tracking
|
|
```
|
|
|
|
Baseline MAE targets: 1-day=0.2314, 3-day=0.5424, 7-day=0.6391
|
|
|
|
## Anti-Patterns
|
|
|
|
- Don't change model architecture without updating `scripts/train_model.py` and `scripts/inference_*.py`
|
|
- Don't load `best_model.pt` without matching the exact `SpatialTemporalGCN` constructor args
|
|
- Don't skip ONNX export validation after architecture changes
|
|
- Don't train without MLflow logging
|