Skip to content

CrimeHotspotSim is a JupyterLab project that analyzes Los Angeles crime data (2020–present) to forecast hotspots and simulate preventative interventions. It cleans data, generates spatio-temporal features, and visualizes interactive hotspot maps to explore the impact of different strategies.

Notifications You must be signed in to change notification settings

coderzmac/CrimeHotspotSim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CrimeHotspotSim 🔍🗺️

A spatio-temporal hotspot mapping tool that forecasts where crime is most likely to occur in Los Angeles and simulates the impact of preventative interventions.


Overview

CrimeHotspotSim is a research-driven project that leverages crime data (2020–present) to predict high-risk areas in Los Angeles. The project’s main contribution is the ability to simulate interventions (for example, adding 10 patrol cars to a grid, or increasing pedestrian activity by 5%) and generate counterfactual hotspot maps that estimate how predicted crime risk shifts under different scenarios.

This approach provides policymakers, law enforcement, and researchers with a way to explore strategies virtually before implementing them in real life.


Features

  • Preprocess large-scale crime datasets for analysis and modeling.
  • Categorize raw crime descriptions into standardized groups (e.g., THEFT, ASSAULT, FRAUD).
  • Engineer spatio-temporal features (Year, Month, Hour, DayOfWeek).
  • Visualize hotspots on an interactive Los Angeles map using Folium.
  • Simulate preventative interventions (patrol allocation, pedestrian activity).
  • Export cleaned datasets for further modeling or research.

Project Structure

CrimeHotspotSim/
│
├── data/ # Raw & processed datasets (ignored in Git)
│ ├── raw/ # Place original CSVs here (e.g., crime.csv)
│ └── processed/ # Outputs after preprocessing
│
├── notebooks/ # Jupyter notebooks (exploration, preprocessing)
│ └── preprocessing.ipynb
│
├── src/ # Python source code
│ ├── preprocessing.py # Cleaning & feature engineering
│ ├── modeling.py # Training & evaluation
│ └── visualization.py # Hotspot map generation
│
├── visualizations/ # Output plots & interactive maps
│
├── .gitignore # Ensures raw data is not uploaded to GitHub
├── requirements.txt # Python dependencies
└── README.md # Project documentation


Installation

Clone the repository and install dependencies:

git clone git@github.com:cOderZmAk/CrimeHotspotSim.git
cd CrimeHotspotSim

# Create virtual environment
python -m venv .venv
source .venv/bin/activate      # On Mac/Linux
.venv\Scripts\activate         # On Windows

# Install dependencies
pip install -r requirements.txt

Usage

  1. Place the raw dataset (crime.csv) into data/raw/.
  2. Open JupyterLab:
    jupyter lab
    

Run the notebooks in order: preprocessing.ipynb → cleans data and creates processed parquet file. hotspot_mapping.ipynb → generates LA crime hotspot visualizations. simulation.ipynb → runs counterfactual experiments (e.g., add patrols). Check visualizations/ for exported maps (.html) you can open in a browser.


About

CrimeHotspotSim is a JupyterLab project that analyzes Los Angeles crime data (2020–present) to forecast hotspots and simulate preventative interventions. It cleans data, generates spatio-temporal features, and visualizes interactive hotspot maps to explore the impact of different strategies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •