Skip to content

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Based Predictive Policing and Crime Heatmap System

Overview

The AI Based Predictive Policing and Crime Heatmap System is a data-driven web application designed to analyze historical crime data and predict future crime trends. The system uses machine learning models to forecast potential crime hotspots and visualize them on an interactive map.

This project helps law enforcement agencies identify high-risk areas, allocate police resources efficiently, and take preventive measures to reduce crime.


Problem Statement

Traditional crime analysis methods rely heavily on manual data interpretation and reactive strategies. Police departments often respond to incidents after they occur rather than proactively preventing them.

This project addresses these issues by:

  • Predicting crime trends using machine learning
  • Visualizing crime hotspots geographically
  • Providing analytical dashboards for decision-making
  • Allowing users to report crimes digitally

Objectives

The main objectives of the project are:

  • Analyze historical crime data
  • Predict future crime patterns using AI models
  • Identify crime hotspots using geospatial visualization
  • Provide an interactive dashboard for crime analytics
  • Enable citizens to report crimes through a web interface

Key Features

Crime Prediction

Uses machine learning models such as Random Forest and XGBoost to predict different types of crimes.

Crime Heatmap

Displays crime density and hotspots on an interactive map using geospatial visualization.

Dashboard Analytics

Provides charts and KPIs showing:

  • Crime distribution
  • Yearly trends
  • Crime categories
  • City-wise statistics

Crime Reporting System

Allows users to report incidents through the web application.

Authentication System

Secure login and registration using JWT-based authentication.


System Architecture

Frontend (React + Tailwind CSS)

API Layer (FastAPI Backend)

Machine Learning Model (Random Forest / XGBoost)

Database (PostgreSQL / CSV dataset)


Technology Stack

Updated Backend Architecture

The backend now separates route handling from reusable service logic:

  • app/services/risk_scoring.py centralizes weighted risk-score calculation and explains the top forecast drivers.
  • app/services/forecast_service.py builds forecast payloads with model source, prediction batch, risk explanation, and decision-support guidance.
  • app/services/ai_governance.py exposes responsible-AI guardrails for allowed uses, prohibited uses, and human-review requirements.

This keeps API routes smaller and makes the AI decision-support logic easier to test, explain, and audit.

Responsible AI Controls

The system treats predictions as aggregate decision-support signals, not automated enforcement decisions.

  • Forecasts include a decision-support notice.
  • Risk scores expose their weighted drivers.
  • Patrol recommendations require human review and local context.
  • The system explicitly prohibits individual-level prediction and automatic punitive action.

Frontend

  • React.js
  • Vite
  • Tailwind CSS
  • MapLibre GL
  • Deck.gl

Backend

  • FastAPI
  • Python
  • Uvicorn

Machine Learning

  • Scikit-learn
  • XGBoost
  • Pandas
  • NumPy

Database

  • PostgreSQL

Visualization

  • MapLibre GL
  • Deck.gl Heatmap Layer
  • Chart.js / Recharts

Project Structure

ai-predictive-policing-system

├── backend
│ ├── app
│ │ ├── routes
│ │ ├── models
│ │ ├── schemas
│ │ └── services
│ │
│ ├── main.py
│ └── requirements.txt

├── frontend
│ ├── src
│ │ ├── components
│ │ ├── pages
│ │ └── services
│ │
│ ├── package.json
│ └── vite.config.js

├── dataset
├── models
└── README.md

Installation Guide

Clone the Repository

git clone https://github.com/ankuryadavgithub/ai-predictive-policing-system.git
cd ai-predictive-policing-system

Backend Setup

Create virtual environment

python -m venv venv

Activate environment

Windows

venv\Scripts\activate

Install dependencies

pip install -r requirements.txt

Run the backend server

uvicorn app.main:app --reload

Backend will start at:

http://127.0.0.1:8000

Frontend Setup

Navigate to frontend

cd frontend

Install dependencies

npm install

Run development server

npm run dev

Frontend will start at:

http://localhost:5173

Machine Learning Model

The system trains machine learning models using historical crime data.

Models used:

  • Random Forest Regressor
  • XGBoost Regressor

These models predict:

  • Total IPC crimes
  • Crime category trends
  • Future crime patterns (2026–2030)

The best model is selected based on RMSE performance .


Crime Heatmap Visualization

The application uses:

  • MapLibre GL
  • Deck.gl Hexagon Layer

to visualize crime intensity on a geographic map.

This helps identify:

  • Crime hotspots
  • High-risk zones
  • Crime clusters

API Endpoints

Authentication

POST /register

POST /login

Crime Data

GET /crimes

GET /crime-stats

Prediction

GET /forecast

Report Crime

POST /report-crime

Future Improvements

  • Real-time crime prediction
  • Integration with police databases
  • Mobile application
  • AI-based anomaly detection
  • Social media crime signal analysis

Conclusion

The AI Based Predictive Policing System demonstrates how machine learning and geospatial analytics can support law enforcement agencies in proactive crime prevention. By analyzing historical crime data and predicting future trends, the system provides actionable insights for improving public safety and resource allocation.


Author

Ankur Yadav

BE Information Technology

Final Year Major Project

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages