This directory contains the files and scripts used for analyzing and preprocessing the "Arrest Data from 2020 to Present" dataset.
The dataset Arrest_Data_from_2020_to_Present.csv contains records of arrests from 2020 to the present, including information about:
- Report and arrest details (ID, type, date, time)
- Geographic information (area, district, address, coordinates)
- Arrestee demographics (age, sex, descent)
- Charge information (group, description, type)
- Processing information (booking details, disposition)
The analysis is performed in the data_analysis.py script, which conducts the following steps:
- Load the raw CSV data
- Display basic information (dimensions, data types, summary statistics)
- Check for missing values
- Convert date and time strings to proper datetime objects
- Extract additional temporal features (year, month, day, weekday, hour)
- Remove rows with missing values in critical columns
- Identify and handle age outliers (restricting to 10-100 years)
- One-hot encode categorical variables (Sex Code, Descent Code, etc.)
- Create location clusters from latitude and longitude data
- Generate weekend arrest flags and weekday numerical mapping
- Create area-specific feature flags for top areas
- Time Series Analysis: Arrests over time by month and year-month trends
- Demographic Analysis: Age distribution overall and by gender
- Geographic Analysis: Arrest distribution by area
- Temporal Patterns: Heatmap of arrests by day of week and hour
- Charge Analysis: Top charge groups and charge types by area
- Feature Correlation: Improved heatmap of correlations between meaningful features
Arrest_Data_from_2020_to_Present.csv: Original datasetdata_analysis.py: Python script for analysis and preprocessingprocessed_arrest_data.csv: Cleaned and processed dataset
The script performs the following preprocessing steps to prepare the data for AI model training:
- Date/Time Conversion: Converting string representations to proper datetime objects
- Missing Value Handling: Removing rows with missing critical information
- Outlier Removal: Filtering out invalid age values outside the 10-100 range
- Feature Engineering: Creating new features from existing data:
- Temporal features (year, month, day, weekday, hour)
- Location clustering based on coordinates
- Weekend/weekday indicators
- Area-specific indicator variables
- Categorical Encoding: One-hot encoding categorical variables with manageable cardinality
To run the analysis script:
cd /path/to/project
python Data/data_analysis.pyThis will generate all visualizations in the Data/plots directory and save the processed dataset to Data/processed_arrest_data.csv.