CityofToronto / bdit_traffic_prophet

Suite of algorithms for predicting average daily traffic on Toronto streets
GNU General Public License v3.0
1 stars 1 forks source link

Traffic Prophet

Traffic Prophet is a suite of Python tools to transform Toronto's historical traffic count data to estimates of annual average daily traffic (AADT) on all city streets. It is based on the Traffic Emissions Prediction Scheme (TEPS) codebase created by Dr. Arman Ganji of the University of Toronto (paper).

Traffic Prophet currently remains under development. On initial release, it will contain:

Alongside the Traffic Prophet codebase, this repo also contains some literature review, a number of development and experimental notebooks in a sandbox folder, utilities for working with TEPS and scripts for helping to generate input data for the model.

Folder Structure

Traffic Prophet Codebase

Requirements

As given by requirements.txt, the Traffic Prophet codebase requires:

hypothesis>=5.5.4
numpy>=1.18
pandas>=1.1
psycopg2>=2.8.4
pytest>=5.4
scikit-learn>=0.22
statsmodels>=0.11.1
tqdm>=4.43

Individual Jupyter notebooks in sandbox may require other packages (including notebook to actually run Jupyter notebooks, of course).

Usage

Installation

traffic_prophet itself only requires a Python environment with the packages listed above. It, however, also relies on input data from Postgres (or zip files, but this is a legacy ingestion method developed for testing against TEPS). The required Postgres tables are:

prj_volume.tp_centreline_lonlat.sql
prj_volume.tp_centreline_volumes.sql
prj_volume.tp_daily_volumes.sql

The scripts to create these are located in input_data/flow.

traffic_prophet also assumes there to be a user-generated config.py file inside the traffic_prophet/ directory. Also in that directory is a config_template.py file that shows how to create config.py.

For a default configuration, simply copy the contents of config_template.py into a new config.py file.

Importing

To import traffic_prophet, add this folder to the Python PATH, eg. with

import sys
sys.path.append('<FULL PATH OF bdit_traffic_prophet>')

Testing

To test the package, run the following in this folder:

pytest -s -v --pyargs traffic_prophet

License

Traffic Prophet is licensed under the GNU General Public License v3.0 - see the LICENSE file.