GithubHelp home page GithubHelp logo

geospatial_optimal_transport's Introduction

Earth mover distance for spatiotemporal predictions

Installation:

The code can be installed via pip in editable mode in a virtual environment with the following commands:

git clone https://github.com/mie-lab/geospatial_optimal_transport
cd  geospatial_optimal_transport
python -m venv env
source env/bin/activate
pip install -e .

This installs the package called geoemd in your virtual environment, together with all dependencies.

Data download and preprocessing:

Public bike sharing data from Montreal were downloaded here. A script is provided to read all data and to convert it into the hourly number of bike pick-ups per station:

python preprocessing/bikes_montreal.py --path path/to/downloaded/folder

The script will output the preprocessed data into the same folder.

Similarly, we provide a preprocessing script for the charging data (downloaded here: https://gitlab.com/smarter-mobility-data-challenge/tutorials); however, it builds up on the notebook from the winning team of the challenge:

python preprocessing/charging.py

Train and test a model

We use the darts library for time series prediction.

python train_test.py [-h] [-d DATA_PATH] [-s STATION_PATH] [-o OUT_PATH] [-c CONFIG] [-m MODEL] [--multi_vs_ind MULTI_VS_IND] [-r RECONCILE] [-x HIERARCHY] [-l LAGS] [--output_chunk_length OUTPUT_CHUNK_LENGTH] [--n_epochs N_EPOCHS] [--x_loss_function X_LOSS_FUNCTION] [--x_scale X_SCALE] [--num_stacks NUM_STACKS] [--lags_past_covariates LAGS_PAST_COVARIATES] [--y_clustermethod Y_CLUSTERMETHOD][--y_cluster_k Y_CLUSTER_K] [--model_path MODEL_PATH] [--load_model_name LOAD_MODEL_NAME] [--ordered_samples] [--optimize_optuna]

E.g. we ran it with

python scripts/train_test.py  -d data/bikes/test_pickup.csv     -s data/bikes/test_stations.csv     -o outputs/bikes     --model_path trained_models/bikes  --model nhits --n_epochs 100 --x_loss_function emdunbalancedspatial

This will train with a Sinkhorn loss (unbalanced OT) in the NHiTS model, and will save the model in the folder trained_models/bikes, and save the output in outputs/bikes.

Evaluation

Our evaluation script is applied on a whole folder with the outputs from several models, and saves the results in a folder with the same name + "_plots", e.g., outputs/bikes_plots:

python scripts/evaluate.py -n bikes --redo 

geospatial_optimal_transport's People

Contributors

ninawie avatar

Stargazers

Konstantin Klemmer avatar

Watchers

Yanan Xin avatar NISHANT KUMAR avatar Ye Hong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.