Skip to content

A personal Python project to predict the flow of rivers, in particular the Dranse in Haute-Savoie, France.

License

Notifications You must be signed in to change notification settings

maxnolte/river_forecast

Repository files navigation

river_forecast

Predicting the flow of the river Dranse

version

river_forecast is a Python application for predicting the flow of rivers. It is currently limited to the Dranse in Haute-Savoie, France, a popular river for whitewater kayaking and rafting.

In the standard configuration, river_forecast predicts the flow of the river Dranse in France in real time using gradient boosting (XGBoost). The prediction is currently solely relying on the past water flow. Additional variables such as recent and predicted rainfall will be included in the future. However, even without rain data, the forecast outperforms a naive forecast (see below).

The recent flow data of the Dranse is downloaded through the rivermap.ch API. Hourly training and test data (01/2016-06/2020) has been provided by the French Government's Banque Hydro.

The model is currently deployed on Google Cloud, where a new prediction is generated every 15 mins. Below is the latest prediction:

Link to lastest forecast: https://storage.googleapis.com/river_forecast/forecast.png

Model Fitting & Performance

Note that most models were fitted in Google Colab and then transferred and tested in river_forecast. The notebook describing the fitting of the currently best performing model (XGBoost) can be found here.

Below is the full data set. Train and validation sets were used in the Colab for model tuning, test data only for comparison of the final models:

Train-test split

The best performing model uses gradient boosting (XGBoost). All models in the error comparison below can currently be used to make predictions:

Model errors

Below are some example predictions for XGBoost in the test data:

Prediction examples

Installation

river_forecast has been tested using Anaconda on Ubuntu, Windows, and Windows Subsystem for Linux.

To install the right versions, run the following in a new conda environment:

conda install --file conda-spec-file.txt

Warning: currently contains many not required packages.

Usage

To generate the current standard prediction, run:

python bin/create_river_forecast_local.py

Warning: a private rivermap.ch API is needed (PRIVATE_RIVERZONE_API_KEY). Get in touch with me (maxnolte) if you are interested, and I'll ask the admins of rivermap.ch.

Other experimental models (SARIMA, LSTM, Naive) can be run by changing the model calls in the script above.

The model is currently run on a Google Cloud Compute Engine VM using:

nohup python bin\launch_gcp_compute_engine_schedule.py &

Contributing

river_forecast is in its early stages and highly experimental. Please get in touch with me (maxnolte) if you have any feedback or suggestions!

Next Steps

  • Include precipitation data.
  • Show forecast in dash application.
  • Generalize to more rivers from rivermap.ch (Let me know if you have a preference!).

License

MIT

About

A personal Python project to predict the flow of rivers, in particular the Dranse in Haute-Savoie, France.

Resources

License

Stars

Watchers

Forks