Skip to content

Repository files navigation

LA Crime Arrest Prediction

About This Project

For this project, I used incident data released by the Los Angeles Police Department (LAPD) from 2023 and 2024 to predict whether an arrest would be made based on information known at the time an incident was reported.

The dataset includes details about the incident, such as when and where it happened, victim demographics, weapon involvement, and location descriptions. By looking for patterns within these variables, I wanted to see which factors were most connected to arrests and how accurately different machine learning models could predict whether an arrest would occur.

This is a binary classification problem, meaning each incident is placed into one of two categories:

  • 1 = an arrest was made
  • 0 = no arrest was made

Data

The data came from the Los Angeles Open Data portal.

Crime Data from 2020 to 2024.

https://data.lacity.org/Public-Safety/Crime-Data-from-2020-to-2024/2nrs-mtv8/about_data

Although the original dataset contains observations from 2020 through 2024, I only used data from 2023 and 2024 because of the size of the full dataset.

Why Is This Relevant?

Los Angeles is a major economic and cultural center in the United States, and LAPD is one of the largest police departments in the country. Looking at arrest patterns can help show which types of incidents and variables are most associated with arrests.

At the same time, predictive policing models are controversial because historical data can reflect existing biases. For example, if certain neighborhoods have historically been policed more heavily, a model trained on that data may pick up and reinforce those same patterns.

Because of this, I think it is important to look at these models carefully. They can still be useful for understanding patterns in policing, identifying possible inequalities in enforcement, and seeing whether certain variables have a stronger influence on arrest outcomes than others.

What I Did

Before building any models, I first had to do a lot of data cleaning and preparation.

This included:

  • Removing variables that were not useful for the analysis
  • Converting variables into the correct formats
  • Handling missing values
  • Labeling some missing categorical values as "Unknown"
  • Preparing the predictor variables
  • Splitting the data into training and testing sets
  • Creating a preprocessing recipe
  • Using 10-fold cross-validation

After that, I tested several classification models:

  • Logistic Regression
  • Linear Discriminant Analysis
  • Quadratic Discriminant Analysis
  • Lasso Regression
  • Decision Tree
  • Random Forest
  • K-Nearest Neighbors

The goal was to compare the models and determine which one performed best when predicting whether an incident would result in an arrest.

Model Evaluation

One of the biggest issues with this dataset was class imbalance.

Just over 90% of incidents did not result in an arrest, which means a model could have a very high accuracy just by predicting "no arrest" almost every time.

Because of this, accuracy by itself would have been misleading.

Instead, I mainly used ROC AUC to compare the models because it better measures how well a model can separate arrest cases from non-arrest cases across different classification thresholds.

Final Model

After testing and comparing the different models, Logistic Regression performed the best overall.

The model was still far from perfect, but it performed better than the other models I tested and gave the strongest overall results for this project.

This also showed one of the difficulties of working with real-world crime data. There are many factors that can affect whether an arrest happens, and not all of those factors are necessarily included in the dataset.

Repository Files

  • analysis.ipynb — Main analysis, data cleaning, and modeling
  • analysis.html — Full rendered analysis
  • analysis_report_la_crime.pdf — PDF version of the final analysis
  • models.ipynb — Additional model testing
  • crime_cleaned.csv — Cleaned dataset
  • Figures/ — Visualizations created during the project
  • CSV_Results/ — Model results
  • Saved_Models/ — Saved model files

Full Report

The full report with the data cleaning, modeling process, visualizations, results, and conclusions can be found in:

analysis_report_la_crime.pdf

The full code used for the project can also be found in:

analysis.ipynb and models.ipynb

About

Machine learning classification project predicting arrest outcomes using LAPD incident data.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages