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 made0= no arrest was made
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.
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.
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.
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.
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.
analysis.ipynb— Main analysis, data cleaning, and modelinganalysis.html— Full rendered analysisanalysis_report_la_crime.pdf— PDF version of the final analysismodels.ipynb— Additional model testingcrime_cleaned.csv— Cleaned datasetFigures/— Visualizations created during the projectCSV_Results/— Model resultsSaved_Models/— Saved model files
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