Skip to content

ruheil/ML-CodeStacker

Repository files navigation

CityX Crime Watch Dashboard

A comprehensive crime analytics platform for visualizing and analyzing crime data in CityX. This interactive dashboard provides crime trend analysis, report processing, crime classification, and geospatial visualization.

Deployed container

Features

  • Crime Analytics: Temporal, categorical, and severity analysis of crime data
  • Report Processing: Extract information from police reports (PDF format)
  • Prediction & Classification: Classify crime descriptions into categories with severity ratings
  • Geospatial Analysis: Visualize crime data on interactive maps (heatmap, cluster, severity)

Prerequisites

  • Python 3.11+
  • pip (Python package manager)

Installation

  1. Clone the repository:

    git clone https://github.com/ruheil/ML-CodeStacker.git
  2. Create and activate a virtual environment (recommended):

    # Windows
    python -m venv venv
    venv\Scripts\activate
    
    # macOS/Linux
    python -m venv venv
    source venv/bin/activate
  3. Install the required dependencies:

    pip install -r requirements.txt

Optional Model File

For enhanced crime classification:

  • crime_classifier.joblib: Pre-trained crime classification model

If this file is not present, the application will create a simple model on the fly.

Running the Application

Launch the Streamlit application:

streamlit run app.py

The dashboard will open in your default web browser at http://localhost:8501.

Deploying the Application

Option 1: Streamlit Community Cloud

  1. Push your code to a GitHub repository
  2. Sign up at streamlit.io/cloud
  3. Create a new app and connect to this GitHub repository
  4. Select the repository, branch, and app.py as the main file
  5. Click "Deploy"

Option 2: Docker Deployment

  1. Use the Dockerfile provided.

  2. Build and run the Docker container:

    docker build -t cityx-crime-watch .
    docker run -p 8501:8501 cityx-crime-watch

Option 3: Cloud Service Deployment

The application can be deployed to any cloud service provider that supports Python applications:

  1. Prepare your application with the necessary configuration file (requirements.txt)
  2. Follow the cloud provider's specific deployment instructions
  3. Set up the appropriate scaling and networking options
  4. Deploy your application using the provider's CLI or web interface

Most cloud providers (AWS, Google Cloud, Azure, DigitalOcean, etc.) offer services to deploy containerized applications, so the Docker approach in Option 2 can often be adapted for cloud deployment.

How the Project Works

Data Processing

  1. The application loads crime data from Competition_Dataset.csv
  2. Data is preprocessed to extract timestamps, coordinates, and assign severity levels
  3. For classification, the app loads a pre-trained model or creates one on demand

Dashboard Modules

1. Crime Analytics

  • Filtering: Filter crime data by year, district, crime type, and severity
  • Temporal Analysis: Visualize crime patterns by hour, day, and month
  • Categorical Analysis: View top crime categories and distribution by district
  • Severity Analysis: Analyze crime severity distribution and district averages

2. Report Processing

  • Upload police reports in PDF format
  • Extract key information (report number, date, location, description, etc.)
  • Classify crimes based on descriptions
  • Display extracted information and incident location on a map

3. Prediction & Classification

  • Input crime descriptions for classification
  • View predicted crime category and severity level
  • See similar crimes from the database

4. Geospatial Analysis

  • View crime data on interactive maps
  • Choose between heat maps, cluster maps, and severity maps
  • Add new incidents to the map for analysis

Acknowledgments

  • Al Ruheil Al Ruheili © 2025

About

This is my submission to Rihal's ML CodeStacker 25

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published