A python package to help conduct different various types of crime analysis. Mostly a collection of various functions I have used over the years.
Andrew Wheeler
To install this package from GitHub, you can use pip:
pip install git+https://github.com/apwheele/crimepy.git
For now, I would suggest installing editable, since it is in a very early stage. E.g.
git clone https://github.com/apwheele/crimepy.git
cd ./crimepy
pip install -e .
And then just periodically do a git pull
to get the most recent version.
See the notebooks folder for example analyses:
- Aoristic analysis
- DBScan hotspots
- Prioritizing Call Ins via Dominant Sets
- Time Series Charts
- Patrol Districting with Workload Equality
- SPPT Compare Pre to Post Crime
- Querying public Socrata or ESRI data
- Example Interactive Maps with Folium
- Weighted Displacement Difference to See Changes over Time
Additional examples in Notebooks and documentation (contributors welcome!)
- Funnel charts
- nearby chains
- SPPT crime to police activity example
- small sample Benford/Day of week functions & example
- full docstrings for all functions
- tests
- github actions for code quality and pytest
- try patrol districting with googles ORtools, see how fast it runs
- simpler tests for districting
- Folium example for lines and graduated circles
- scan statistic (see this blog post for R implementation)
Other additional methods I may add (if you want these, let me know):
- synthetic control using Lasso (blog post)
- network spillovers optimal assignment (blog post)
- network experiment design (Notebook)
- ?survey duplicates? (Notebook)
Suggestions are always welcome -- direct contributions are a better way to get the items you want in the codebase.
Don't know where to get started? Check out my introductory book on python for crime analysts, Data Science for Crime Analysis with Python
-
Wheeler, A. P. (2016). Tables and graphs for monitoring temporal crime trends: Translating theory into practical crime analysis advice. International Journal of Police Science & Management, 18(3), 159-172. Preprint
-
Wheeler, A. P. (2019). Creating optimal patrol areas using the p-median model. Policing: An International Journal, 42(3), 318-333. Preprint
-
Wheeler, A. P., & Kovandzic, T. V. (2018). Monitoring volatile homicide trends across US cities. Homicide Studies, 22(2), 119-144. Preprint
-
Wheeler, A. P., McLean, S. J., Becker, K. J., & Worden, R. E. (2019). Choosing representatives to deliver the message in a group violence intervention. Justice Evaluation Journal, 2(2), 93-117. Preprint
-
Wheeler, A. P., & Ratcliffe, J. H. (2018). A simple weighted displacement difference test to evaluate place based crime interventions. Crime Science, 7(1), 11. (Crime Science is an open journal)
-
Wheeler, A. P., & Reuter, S. (2021). Redrawing hot spots of crime in Dallas, Texas. Police Quarterly, 24(2), 159-184. Preprint
-
Wheeler, A. P., Riddell, J. R., & Haberman, C. P. (2021). Breaking the chain: How arrests reduce the probability of near repeat crimes. Criminal Justice Review, 46(2), 236-258. Preprint
-
Wheeler, A. P., Steenbeek, W., & Andresen, M. A. (2018). Testing for similarity in area‐based spatial patterns: Alternative methods to Andresen's spatial point pattern test. Transactions in GIS, 22(3), 760-774. Preprint