This project analyzes crime data from 2010 to 2019 using machine learning techniques to predict violent crimes based on various features such as victim demographics, location characteristics, and time of occurrence.
The project implements a logistic regression model to predict whether a crime is violent based on multiple features including:
- Victim's age
- Time of occurrence
- Location (latitude and longitude)
- Victim's race/ethnicity
- Premise type (e.g., alley, apartment, business, educational location, etc.)
The model includes various binary features for:
- Different premises (15+ location types)
- Victim's race/ethnicity (White, Black, Hispanic, Other)
- Violent crime classification
- Geographic coordinates
-
Data cleaning:
- Removal of records with age = 0
- Filtering specific crime codes (944, 954)
- Filtering specific premise codes (601, 750, 803)
- Random sampling of 2,500 records for analysis
-
Feature engineering:
- Creation of binary indicators for different premises
- Encoding of victim race/ethnicity
- Classification of violent crimes based on crime codes
The project uses logistic regression (glm with binomial family) to predict violent crimes. The implementation includes:
- Training/testing split (80/20)
- 10-fold cross-validation
- Mean Square Error (MSE) calculation
- Root Mean Square Error (RMSE) reporting
To run this project, you need:
- R programming environment
- Required R packages:
- base R statistical functions
- CSV file reading capabilities
- Ensure your crime data CSV file is properly formatted and accessible
- Update the file path in the script to point to your data file
- Run the R script to:
- Load and process the data
- Train the model
- Evaluate the model's performance
The model's performance is evaluated using:
- Cross-validation with 10 iterations
- RMSE (Root Mean Square Error) calculation for each iteration
- Average RMSE across all iterations
Bao Khoi Bui, Sally Alakeel, Max Ouellette, Gabriel Mena, Luis Waldo