{"id":18795693,"url":"https://github.com/binste/chicago_safepassage_evaluation","last_synced_at":"2025-08-04T02:10:16.350Z","repository":{"id":162264058,"uuid":"142584819","full_name":"binste/chicago_safepassage_evaluation","owner":"binste","description":"Evaluation of Chicago's Safe Passage program","archived":false,"fork":false,"pushed_at":"2018-08-21T16:50:55.000Z","size":66478,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-29T16:56:00.222Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://binste.github.io/basic_reproducibility_guide/example_project/introduction","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binste.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-27T14:06:11.000Z","updated_at":"2018-08-21T16:49:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"9c1fd6b6-d0e8-4ffb-bb77-b677e29099d3","html_url":"https://github.com/binste/chicago_safepassage_evaluation","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binste%2Fchicago_safepassage_evaluation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binste%2Fchicago_safepassage_evaluation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binste%2Fchicago_safepassage_evaluation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binste%2Fchicago_safepassage_evaluation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binste","download_url":"https://codeload.github.com/binste/chicago_safepassage_evaluation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239720218,"owners_count":19686078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T21:35:02.913Z","updated_at":"2025-02-19T19:26:18.973Z","avatar_url":"https://github.com/binste.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":" # Chicago's Safe Passage Program to Prevent Crime: Is It Worth the Dime?\u003c!-- omit in toc --\u003e\n- [Overview](#overview)\n- [Software environment](#software-environment)\n- [Hardware](#hardware)\n- [Data](#data)\n- [Order of execution](#order-of-execution)\n- [Analysis notebooks](#analysis-notebooks)\n- [How to run it](#how-to-run-it)\n    - [Run it in a conda environment](#run-it-in-a-conda-environment)\n    - [Run it in a Docker container](#run-it-in-a-docker-container)\n\n## Overview\nThis repository contains an example project for [A Basic Guide to Reproducible Research](https://binste.github.io/basic_reproducibility_guide/). It is an analysis of the effect of Chicago's Safe Passage program on crime counts. The program aims at keeping students safe on their way to school by posting civilian guards along various routes to the participating schools. The empirical approach chosen for the analysis follows one of the specifications in the working paper [\"Do More Eyes on the Street Reduce Crime? Evidence from Chicago’s Safe Passage Program\"](https://ignaciomsarmiento.github.io/assets/Safe_Passage_WP.pdf) by Daniel McMillen, Ignacio Sarmiento-Barbieri, and Ruchi Singh from June 22, 2017. The analysis aims to replicate some of their results. For more information on the replication, as well as an introduction on the topic and a summary of the analysis and the results, see the corresponding [website](https://binste.github.io/basic_reproducibility_guide/example_project/introduction).\n\nThis policy evaluation is part of my master thesis (2018) at the University of Zurich under the supervision of [Prof. Pietro Biroli](https://sites.google.com/site/pietrobiroli/home).\n\n## Software environment\nThe data preparation was done in Python using Jupyter notebooks. R was used for the estimation of the Poisson regression. Details on the exact versions as well as additional packages can be found in the [`environment.yml`](environment.yml) file, which can also be used to recreate the conda environment used to create this analysis. As an operating system, macOS High Sierra 10.13.5 was used.\n\n## Hardware\nThe analysis was developed on a 3.1 GHz Intel Core i5 with 16 GB RAM. However, a reproduction of the results was tested and worked with only 10 GB RAM in a Docker container.\n\n## Data\nWith the exception of the crime dataset, all raw data files are provided under `data/raw`. The crime dataset is over 1.5 GB and could therefore not be hosted on GitHub. However, the notebook in the folder `0_download_data` will by default download it for you and put it in the correct folder. The information on crimes should not change much for the years used in this analysis and a download from the original source should work. Note, however, that the results still might vary slightly if you reproduce this due to the download of the crimes dataset. If you want exactly the same crimes dataset as I have, open up a GitHub issue and I can look into it.\n\nSome of the processed datasets are included. However, the dataset used to estimate the Poisson regressions (`est_df`) could, due to its size, not be uploaded to GitHub. It will be reproduced if you follow the order of execution explained in the following section.\n\nFor a detailed description of all data sources used, see the section \"Data\" in the [Appendix](https://github.com/binste/chicago_safepassage_evaluation/blob/master/reports/appendix/Appendix.pdf).\n\n## Order of execution\nTo reconstruct the results starting out from the raw data, run all notebooks in the `notebooks` folders in the order of their numbering. No other scripts have to be run apart from the notebooks. The `src` folder contains scripts with only functions, which are imported by the notebooks.\n\nShould you want to run the whole pipeline with one command, you can do this using the Python script `run_ipynb.py` which resides in the root folder of the project:\n```bash\npython run_ipynb.py 0_download_data 1_prepare_data 2_set_up_crime_database 3_match_datasets 4_combine_for_analysis 5_analysis\n```\nNote however, that this will not give you much of an indication on the progress of the computations, you'll only see the name of the notebook currently processed. This can take up to multiple hours, depending on your hardware.\n\n## Analysis notebooks\nAs the analysis notebooks are probably of the most interest (they produce the main figures and results), the main two are briefly described in the following. They can be found in the folder `notebooks/5_analysis`.\n\n| Notebook | Description |\n| -------- | ----------- |\n| `0.0-binste-estimation-poisson.ipynb` | Estimates all the Poisson regressions for both violent and property crimes and saves models as well as results into the folder `model`. [![nbviewer](https://img.shields.io/badge/render-nbviewer-orange.svg)](https://nbviewer.jupyter.org/github/binste/chicago_safepassage_evaluation/blob/master/notebooks/5_analysis/0.0-binste-estimation-poisson.ipynb)|\n| `1.0-binste-analyze-crime-results-census-block-level.ipynb` | Replicates Figure 3, Figure A.2, Table 1, and Table 10 (column 3 and 7) from McMillen et al. (2017) and compares them to the originals. The notebook also produces additional figures for the website. [![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/binste/chicago_safepassage_evaluation/master?filepath=notebooks%2F5_analysis%2F1.0-binste-analyze-crime-results-census-block-level.ipynb) [![nbviewer](https://img.shields.io/badge/render-nbviewer-orange.svg)](https://nbviewer.jupyter.org/github/binste/chicago_safepassage_evaluation/blob/master/notebooks/5_analysis/1.0-binste-analyze-crime-results-census-block-level.ipynb)|\n\n\u003e **Tip**: To view static versions of the Jupyter notebooks in your browser, you can paste their URL into [Jupyter nbviewer](http://nbviewer.jupyter.org/).\n\n## How to run it\nIf you are not sure how to set up the software specified in `environment.yml` to rerun the analysis, you can use one of the following two options:\n\n### Run it in a conda environment\nDownload the repository as .zip file from GitHub and unpack it or clone it using:\n```bash\ngit clone https://github.com/binste/chicago_safepassage_evaluation\n```\nand then install and activate the conda environment by running:\n```bash\nconda env create -f environment.yml\nconda activate speval\n```\nNow start a Jupyter notebook server in the root directory of the project:\n```bash\njupyter notebook\n```\nSee [Order of execution](#order-of-execution) on how to proceed.\n\nThis approach should give you the exact same Python and R version as well as the same versions of the main packages used. However, system dependencies might differ and I was not able to test it on a Windows machine.\n\n### Run it in a Docker container\nShould you have problems with the above approach due to your operating system, you can also run the analysis in a tested and operating-system-independent environment (using Docker). In the following, I will explain all the necessary steps and use the amazing tool repo2docker, which will copy the repository to your own computer and setup everything for you.\n\n1. Install the [Docker Community Edition](https://store.docker.com/search?type=edition\u0026offering=community) for your operating system\n2. Set the available memory for Docker to 10 GB and the number of CPU cores to 2.\n    * On Mac this can be set by clicking on the Docker symbol in the status bar -\u003e Preferences -\u003e Advanced\n3. Install repo2docker from source to get the latest version:\n    ```bash\n    git clone https://github.com/jupyter/repo2docker.git\n    cd repo2docker\n    pip install -e .\n    ```\n4. Build and launch Docker image of GitHub repository:\n    ```bash\n    jupyter-repo2docker https://github.com/binste/chicago_safepassage_evaluation\n    ```\n5. After it run through, there is an URL, which will lead you to a running Jupyter notebook server. There is currently a bug with Jupyter notebooks and Docker, where the displayed URL might not work without a slight modification. To fix it, change the host name before the port to `127.0.0.1`. Example: `http://d2f78b8191fd:55484/?token=...` becomes `http://127.0.0.1:55484/?token=...`.\n\nSee [Order of execution](#order-of-execution) on how to proceed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinste%2Fchicago_safepassage_evaluation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinste%2Fchicago_safepassage_evaluation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinste%2Fchicago_safepassage_evaluation/lists"}