Machine learning pipeline for river-zone rainfall forecasting, with an optional sediment hotspot prediction module for reservoir monitoring.
The rainfall model is trained from historical Open-Meteo weather data instead of repeated live samples. The sediment module can then consume rainfall predictions alongside satellite imagery, flow, terrain, and land-use features.
- Downloads hourly historical weather data for 14 Indian river zones.
- Builds lag, rolling average, trend, and time-based rainfall features.
- Trains an XGBoost regressor for next-hour rainfall prediction.
- Produces live rainfall predictions from current Open-Meteo forecast data.
- Includes a separate PyTorch-based sediment hotspot package. See
SEDIMENT_HOTSPOT.md.
graph TD
subgraph Data Acquisition
OM[Open-Meteo API] --> Fetch[fetch_historical_weather.py]
Fetch --> RawData[(historical_weather.csv)]
end
subgraph Data Processing
RawData --> Eng[feature_engineering.py]
Eng --> Features[(training_dataset.csv)]
end
subgraph Modeling & Prediction
Features --> Train[train_model.py]
Train --> Model[rainfall_model.pkl]
Model --> PredictLive[river_weather_predictions.py]
OM --> PredictLive
PredictLive --> Outputs[(rainfall_predictions.csv)]
end
subgraph Sediment Module & Dashboard
Outputs --> Sediment[Sediment Hotspot Prediction <br> PyTorch]
Sat[Satellite & Terrain Data] --> Sediment
Sediment --> Dash[Streamlit Dashboard <br> dashboards/]
PredictLive --> Dash
end
reservoir/
├── fetch_historical_weather.py # Download historical Open-Meteo data
├── feature_engineering.py # Build ML training features
├── train_model.py # Train rainfall model
├── river_weather_predictions.py # Run live rainfall prediction
├── pipeline.py # Orchestrate fetch, feature, train steps
├── sediment_pipeline.py # Sediment workflow entry point
├── sediment_hotspot/ # Sediment hotspot package
├── scripts/ # Preprocessing and training helpers
├── dashboards/ # Streamlit dashboard
├── configs/ # Example sediment config
└── requirements.txt
Generated data and model outputs are intentionally ignored by Git:
historical_weather.csv
training_dataset.csv
rainfall_model.pkl
rainfall_predictions.csv
data/raw/
data/processed/
data/models/
data/outputs/
python -m venv venv
source venv/bin/activate
pip install -r requirements.txtOpen-Meteo does not require an API key.
Run the full training workflow:
python pipeline.py --allOr run each stage separately:
python pipeline.py --fetch
python pipeline.py --engineer
python pipeline.py --trainExpected generated files:
historical_weather.csv # Raw hourly weather data
training_dataset.csv # Engineered model features
rainfall_model.pkl # Trained XGBoost model
After training, run live predictions:
python river_weather_predictions.pyThis writes rainfall_predictions.csv, which can also be used as an input feature source for sediment hotspot prediction.
Krishna:
K1_Mahabaleshwar- 17.9237, 73.6586K2_Sangli_Almatti- 16.8544, 74.5642K3_Raichur_Kurnool- 16.2076, 77.3463K4_Nagarjuna_Sagar- 16.5750, 79.3167K5_Vijayawada_Delta- 16.5062, 80.6480
Narmada:
N1_Amarkantak- 22.6747, 81.7590N2_Jabalpur- 23.1815, 79.9864N3_Omkareshwar- 22.2452, 76.1510N4_Bharuch- 21.7051, 72.9959
Kaveri:
C1_Talakaveri- 12.3855, 75.4894C2_Kodagu- 12.3375, 75.8069C3_Mysuru_KRS- 12.2958, 76.6394C4_Mettur_Dam- 11.7870, 77.8008C5_Thanjavur_Delta- 10.7867, 79.1378
Raw weather variables:
temperaturehumidityrainfallpressurewind_speedcloud_cover
Engineered variables:
- 1, 2, and 3 hour lag features for each raw variable.
- 3 hour rolling averages for rainfall, humidity, and temperature.
- Pressure, humidity, temperature, and wind change features.
- Hour, day, and month time features.
rainfall_next_hourregression target.rainfall_classcategory for no, light, moderate, and heavy rainfall.
The sediment system combines rainfall predictions with:
- Sentinel-2 or Landsat imagery
- River flow and inflow sequences
- DEM terrain features
- Land-use features
See SEDIMENT_HOTSPOT.md for the public data sources, preprocessing commands, training manifest, inference workflow, and dashboard command.
- Open-Meteo: https://open-meteo.com/
- XGBoost: https://xgboost.readthedocs.io/
- PyTorch: https://pytorch.org/

