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.
- 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)
- Python 3.11+
- pip (Python package manager)
-
Clone the repository:
git clone https://github.com/ruheil/ML-CodeStacker.git
-
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
-
Install the required dependencies:
pip install -r requirements.txt
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.
Launch the Streamlit application:
streamlit run app.pyThe dashboard will open in your default web browser at http://localhost:8501.
- Push your code to a GitHub repository
- Sign up at streamlit.io/cloud
- Create a new app and connect to this GitHub repository
- Select the repository, branch, and
app.pyas the main file - Click "Deploy"
-
Use the Dockerfile provided.
-
Build and run the Docker container:
docker build -t cityx-crime-watch . docker run -p 8501:8501 cityx-crime-watch
The application can be deployed to any cloud service provider that supports Python applications:
- Prepare your application with the necessary configuration file (requirements.txt)
- Follow the cloud provider's specific deployment instructions
- Set up the appropriate scaling and networking options
- 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.
- The application loads crime data from
Competition_Dataset.csv - Data is preprocessed to extract timestamps, coordinates, and assign severity levels
- For classification, the app loads a pre-trained model or creates one on demand
- 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
- 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
- Input crime descriptions for classification
- View predicted crime category and severity level
- See similar crimes from the database
- View crime data on interactive maps
- Choose between heat maps, cluster maps, and severity maps
- Add new incidents to the map for analysis
- Al Ruheil Al Ruheili © 2025