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.
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
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
Uses machine learning models such as Random Forest and XGBoost to predict different types of crimes.
Displays crime density and hotspots on an interactive map using geospatial visualization.
Provides charts and KPIs showing:
- Crime distribution
- Yearly trends
- Crime categories
- City-wise statistics
Allows users to report incidents through the web application.
Secure login and registration using JWT-based authentication.
Frontend (React + Tailwind CSS)
⬇
API Layer (FastAPI Backend)
⬇
Machine Learning Model (Random Forest / XGBoost)
⬇
Database (PostgreSQL / CSV dataset)
The backend now separates route handling from reusable service logic:
app/services/risk_scoring.pycentralizes weighted risk-score calculation and explains the top forecast drivers.app/services/forecast_service.pybuilds forecast payloads with model source, prediction batch, risk explanation, and decision-support guidance.app/services/ai_governance.pyexposes 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.
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.
- React.js
- Vite
- Tailwind CSS
- MapLibre GL
- Deck.gl
- FastAPI
- Python
- Uvicorn
- Scikit-learn
- XGBoost
- Pandas
- NumPy
- PostgreSQL
- MapLibre GL
- Deck.gl Heatmap Layer
- Chart.js / Recharts
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
git clone https://github.com/ankuryadavgithub/ai-predictive-policing-system.git
cd ai-predictive-policing-system
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
Navigate to frontend
cd frontend
Install dependencies
npm install
Run development server
npm run dev
Frontend will start at:
http://localhost:5173
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 .
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
POST /register
POST /login
GET /crimes
GET /crime-stats
GET /forecast
POST /report-crime
- Real-time crime prediction
- Integration with police databases
- Mobile application
- AI-based anomaly detection
- Social media crime signal analysis
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.
Ankur Yadav
BE Information Technology
Final Year Major Project