uv for dependency management
Use uv venv and then uv sync to create the required virtual environment and download the required packages.
After that use uv run <your command> to execute python scripts within the virtual environment or manually activate the virtual environment.
Uses:
- polars
- seaborn
Uses:
- geopandas
- geoplot
- heatmap.py README
- heatmap.py README
- celltower data README
- census data README
- gravity model helpers
- gravity model implementations
- gravity model search algorithms
- data output formats
Main scripts are those that can be executed. Other files are libraries/helper files used for those main scripts.
- preprocess - converts the census data into a single location dataset
- convert - converts the celltower data we have to the common format we use for trips, based on the location data created by process.py
- train - uses the location data and the converted celltower data to generate a gravity model, optimising the parameters of the model to produce more similar trips based on the trip length histogram.
- run - uses a gravity model to generate a certain amount of trips
- eval - produces graphs comparing the real and the model output, producing histogram, CCDF, CDF and KDE plots
- map - produces heightmaps to visualize the relationship between parameters and error metrics
The Makefile contains a simple pipeline to produce the required data (assuming all the datasets are placed correctly), train a model and evaluate it.
We require the following files:
celltower_data/merged_uk_data.csv- needs to contain the celltower datacensus_data/uk_boundaries_merged_2024.csv- needs to contain the boundary datacensus_data/uk_2022.csv- needs to contain the population data
Alternatively, if you have the location data (as loc_data.csv) and the converted celltower data (as real_output.csv) the make command will skip the initial steps.
To use the makefile use: make full-<model name> ITERATIONS=<your iteration number> SEARCH=<your search algorithm>
The makefile defaults to 10 iterations and a search using Nelder-Mead.
For example, to produce our triple-power model use: make full-triplepower ITERATIONS=200