Crime Hotspot Prediction Portal

Crime analytics portal: hotspot map of 400 zones, Random Forest prediction of the likely crime for any zone and time with honest accuracy, zone risk levels, patrol plan, CSV import. Python, Flask, scikit-learn, SQLite.

  • Price: ₹1,999
  • Category: Web App
  • Technology: Python, Flask, scikit-learn (Random Forest), SQLite, Bootstrap 5, Chart.js
  • Includes: Source code + database
  • Suitable for: BCA / B.Sc CS, MCA / M.Sc CS, B.E / B.Tech CSE & IT

Project overview

This is a full crime analytics website that runs on a normal PC. There are two roles. The admin and the officer see the dashboard (incidents, last 30 days against the 30 days before, busiest zone, model accuracy, charts by crime type, hour, weekday and week), the hotspot map (20 x 20 zones, filter by crime type and period, click a zone for its detail), the prediction page (choose a zone or type latitude and longitude, a date and a time; the result gives the likely crime with the chance of all six crime types, the zone risk High / Medium / Low / No history and what the history says), the patrol plan (top 6 zones for a date and a shift with the likely crime), the incident list (filters, paging, export CSV, add an incident), the model page (accuracy, baseline, per-type table, what the model looks at) and the history of predictions (an officer sees only own predictions). The admin also imports CSV files (bad rows are skipped and explained, duplicates are never added twice), loads the real Indore 2018 sample, removes the generated demo data, trains the model again, manages users and reads the audit log. Security: hashed passwords, a lock after 5 wrong passwords, CSRF tokens in every form, role checks on every page, 15-minute idle logout, escaped text, SQL with placeholders. 27 rule tests and 133 web checks are included.

Modules

  1. Login, roles and users: Admin and officer roles; hashed passwords; lock after 5 wrong passwords; admin adds users, resets passwords, closes and opens logins (the last admin cannot be closed).
  2. Zones and incidents: 20 x 20 zone grid from the city box in config.py; validation of date (not in the future), crime type and place; duplicates refused; list with filters and paging; add; delete (admin); CSV export.
  3. Import: CSV import with row-by-row checks and a report (added, duplicates, invalid with the reason); one-click load of the Indore 2018 sample; remove the generated demo data.
  4. Dashboard and hotspot map: Totals, trend against the month before, busiest zone; charts by type, hour, weekday and week; heat grid with type and period filters; zone detail page.
  5. Prediction model: Random Forest on hour, weekday, latitude and longitude; 80/20 split; accuracy, guessing baseline, precision and recall per crime; feature importance; retrain button.
  6. Prediction and risk: Chance of every crime type for a zone, date and time; zone risk level compared with the busiest zone for the same hour window; every prediction is saved with the officer name.
  7. Patrol plan: Top 6 zones for a date and a shift (Morning, Afternoon, Evening, Night) using the same kind of day (weekday or weekend) from the history, with the likely crime.
  8. History and audit: Predictions per officer (admin sees all) with CSV export; audit log of logins, incidents, imports, training, users and predictions.

Requirements

  • Python 3.11
  • Internet once, to install the libraries (about 3 minutes)
  • Windows 10 / 11

How to run this project

  1. Install Python 3.11 from python.org and tick "Add python.exe to PATH" during setup.
  2. Extract the zip and open the project folder (STUDENT_GUIDE.md explains every step in simple words).
  3. Double-click `1_INSTALL.bat` once and wait until it says [OK] (about 3 minutes; it downloads the libraries into a private .venv folder).
  4. Double-click `2_RUN.bat` to start the project. Your browser opens http://127.0.0.1:5000 by itself. If it does not start, double-click `CHECK_SETUP.bat` and read what it says.
  5. Log in as admin / admin123 (officer: officer1 / demo123). The first start trains the model in a few seconds.
  6. Open the Hotspot map and Predict (darkest zone, Friday, 19:00), then Model: explain accuracy against the guessing baseline and why rare crimes such as Murder have low recall. Add an incident and export the list as CSV.

More Web App projects