/project-avalon

Crime Forecast in Vancouver

Primary LanguageJupyter NotebookOtherNOASSERTION


Crime Forecast in Vancouver

  • DSCI-522 Group 23
  • Alias: Project Avalon

๐ŸŒŸ Stakeholders

Our team, in alphabetical order:

  • Orix Au Yeung
  • Ben Chen
  • Mo Norouzi
  • Yiwei Zhang

Welcome to the repository for Project Avalon, a part of the DSCI-522 course by Group 23 in the MDS-V Cohort 8 at UBC.

โญ๏ธ Project Summary

Project Website: https://ubc-mds.github.io/project-avalon/

This project aims to perform statistical analyses on the crimes committed in the City of Vancouver and develop a forecasting algorithm to forecast the number of crimes given a set of lagged values.

We created a model to estimate the frequency of vehicle break-ins each month in Vancouver. It uses historical data to inform its predictions, applying methods that consider both recent occurrences and long-established trends. The chosen approach has an average deviation of about 27 incidents per month from the actual numbers, which is notable given the substantial month-to-month variation in the incident counts. The model's current accuracy demonstrates its potential, and we anticipate that incorporating additional factors, such as weather patterns or significant city events, could enhance its predictive capabilities.

๐Ÿ“˜ Data Source

Crime Data Download, the Vancouver Police Department

๐Ÿ“‹ Dependencies

All required dependencies are listed in this conda environment file.

๐Ÿง‘โ€๐Ÿ’ป How to Reproduce Our Findings

Option 1: Docker/Docker compose (recommended)

Link to the DockerHub Image

For this method, you will need to ensure either Docker Dekstop or Docker Engine is installed and running in your system.

Important Notes:

  • (For Docker Desktop users) The created container will require more than 4GB of RAM to run the analysis notebook. Please ensure the settings in Docker Desktop enables provisioning at least 8GB of RAM to the container.
  • (For Apple Silicon users) Please enable the feature "Use Rosetta for x86/amd64 emulation on Apple Silicon" inside the setting menu. Otherwise, the kernel will not be properly run.

Report Generation Pipeline

Go to the project's root folder and run:

docker compose --profile make-report pull && \
  docker compose --profile make-report up
  • The above script generates the report using GNU Make and Jupyter Book.
  • The final report will be placed under docs/.

JupyterLab Server

Go to the project's root folder and run:

docker compose --profile interactive pull && \
  docker compose --profile interactive up
  • This is best for users who are interested in tinkering with the data, models and report.
  • Use browser to visit http://localhost:8888 and supply the generate token.

Option 2: Local conda environment

  1. Create a new conda environment based on the provided YAML file.
  • Run conda env create --name avalon --file=environment.yaml
  • Then switch to avalon env by clicking the drop-down, and select avalon image
  • Note:
    • If you need the avalon env locally, run conda activate avalon
    • If you added a new package in your local environment.yaml, you need to run conda env update --name avalon --file=environment.yaml to update your local env.
    • In case that jupyter does not recognize the new conda environment, Install ipykernel's kernel spec thru the following command:
conda activate avalon
python -m ipykernel install --user --name avalon --display-name "Python (avalon)"
  1. Ensure all dependencies are installed.
  2. Open Jupyter Notebook or JupyterLab to run the analysis notebook

๐Ÿงช Test Automation

To run tests, execute the following command in the project root directory:

python3 tests/run_all_tests.py

๐Ÿ“Œ Useful URLs

Here are some handy links for quick access:

image

๐Ÿ“– License

All reports contained herein are licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) License. See the license file for more information.

If re-using/re-mixing please provide attribution and link to this webpage.

The software code contained within this repository is licensed under the MIT license. See the license file for more information.