MapMySafety
Data-driven crime insights for Toronto neighbourhoods
Inspiration
Living in a big city like Toronto, we often hear about crime incidents but lack accessible tools to understand safety patterns in our own neighbourhoods. We wanted to empower residents, newcomers, and anyone exploring Toronto with data-driven insights to make informed decisions about where to live, work, and travel.
The question that drove us was: "What if we could predict crime trends and help people stay safer?" With 12 years of Toronto Police Service data at our fingertips, we saw an opportunity to transform raw crime statistics into actionable intelligence through machine learning and beautiful visualizations.
What it does
MapMySafety is a comprehensive full-stack web application that provides:
πΊοΈ Interactive Crime Analytics
- Analyzes 800,000+ crime records across 158 Toronto neighbourhoods
- Sophisticated Crime Index (0-100) using logarithmic scaling for accurate risk assessment
- 6-tier safety rating system from "Very Low Risk" to "Very High Risk"
- Interactive heatmap showing crime density with colour-coded neighbourhood markers
- Click-to-explore detailed crime category breakdowns
π€ AI-Powered Predictions
- Machine Learning models trained on 12 years of historical data
- Predicts future crime counts with 82% accuracy (RΒ² Score: 0.82)
- Classifies crime types with 85% accuracy using Logistic Regression
- Provides top 3 most likely crime types with probability scores
- Compares predictions against historical patterns
- Generates personalized safety recommendations based on predicted crime types
π Data Visualization
- City-wide crime distribution charts with percentage breakdowns
- Neighbourhood-specific statistics and trends
- Historical context comparison (same month in previous years)
- Real-time interactive Folium maps with heat density layers
How we built it
Tech Stack
Frontend:
- React.js for dynamic, responsive UI
- CSS3 with custom glassmorphism effects for modern design
- Professional blue gradient theme (Navy β Cyan)
- Responsive design optimized for desktop and mobile
Backend:
- FastAPI (Python) for high-performance REST API
- Uvicorn ASGI server for async capabilities
- Pandas & NumPy for efficient data processing
- RESTful endpoints serving JSON data
Machine Learning:
- Linear Regression for crime count prediction
- Logistic Regression for multi-class crime type classification
- StandardScaler for feature normalization
- scikit-learn for model training and evaluation
- Features: Year, Month, Historical Count, Location Diversity, Premises Diversity, GPS Coordinates
Data Visualization:
- Folium for interactive map generation
- HeatMap plugin for crime density visualization
- Custom colour gradients (Green β Yellow β Orange β Red)
- CircleMarkers with detailed neighbourhood popups
Data Processing:
- Cleaned and aggregated 800,000+ crime records
- Engineered features for ML models
- Created time-series datasets for predictions
- Normalized data across 158 neighbourhoods
Architecture
Frontend (React) β REST API (FastAPI) β ML Models (scikit-learn)
β Data Processing (Pandas)
β Visualization (Folium)
Development Process
- Data Acquisition: Downloaded Major Crime Indicators dataset from Toronto Police Service
- Data Cleaning: Processed 800,000+ records, handled missing values, normalized neighbourhood names
- Feature Engineering: Created aggregated features (crime counts, location diversity, temporal patterns)
- Model Training: Trained and evaluated Linear Regression and Logistic Regression models
- Backend Development: Built FastAPI server with 10+ endpoints
- Frontend Development: Created React components with interactive UI
- Integration: Connected all components through REST API
- Design & Polish: Implemented professional glassmorphism UI with animations
Challenges we ran into
π΄ Python Version Compatibility
- Challenge: Python 3.14 had breaking changes (removed
cgimodule, changedcollections.Mapping) - Solution: Downgraded to Python 3.12 and installed compatibility packages
π΄ Large Dataset Management
- Challenge: 148 MB CSV file exceeded GitHub's 100 MB limit
- Solution: Excluded data files from Git, documented download instructions in README
π΄ Model Training Complexity
- Challenge: Creating meaningful features from raw crime data
- Solution: Engineered features like location diversity, premises diversity, and temporal patterns
- Implemented sophisticated Crime Index using logarithmic scaling
π΄ Real-time Map Generation
- Challenge: Generating interactive maps on-the-fly for 158 neighbourhoods
- Solution: Optimized Folium rendering, implemented server-side HTML generation
π΄ Data Accuracy
- Challenge: Ensuring predictions were realistic and useful
- Solution: Implemented historical comparison, provided confidence scores, added disclaimer about statistical nature of predictions
π΄ UI/UX Design
- Challenge: Making complex data accessible and visually appealing
- Solution: Created custom glassmorphism design, interactive elements, clear typography, and intuitive navigation
π΄ Month Name vs Number Conversion
- Challenge: Raw data had month names as strings, but predictions needed numeric values
- Solution: Created conversion logic to handle both formats seamlessly
Accomplishments that we're proud of
β¨ Machine Learning Success
- Achieved 82% RΒ² Score for crime count prediction
- Achieved 85% accuracy for crime type classification
- Successfully trained models on 12 years of real-world data
β¨ Data Scale
- Processed 800,000+ crime records
- Analyzed 158 neighbourhoods
- Covered 12 years of historical data (2014-2025)
β¨ User Experience
- Created an intuitive, professional interface that makes complex data accessible
- Implemented smooth animations and transitions
- Built responsive design that works on all devices
β¨ Practical Impact
- Provides actionable safety recommendations
- Helps users make informed decisions about housing and travel
- Makes public safety data accessible to everyone
β¨ Technical Excellence
- Built a production-ready full-stack application
- Implemented proper error handling and data validation
- Created comprehensive API documentation
- Achieved clean, maintainable code architecture
β¨ Innovation
- Combined multiple data visualization techniques (maps, charts, tables)
- Integrated ML predictions with historical context
- Created a unique Crime Index algorithm using logarithmic scaling
What we learned
π Technical Skills
Machine Learning:
- How to prepare real-world data for ML models
- Feature engineering for crime prediction
- Model evaluation and validation techniques
- Balancing accuracy with interpretability
Full-Stack Development:
- Building scalable REST APIs with FastAPI
- State management in React applications
- Async programming in Python
- CORS and API security best practices
Data Science:
- Working with large datasets (800,000+ records)
- Data cleaning and normalization at scale
- Creating meaningful aggregations and metrics
- Time-series data handling
Data Visualization:
- Creating interactive maps with Folium
- Heat density visualization techniques
- Custom colour gradients for data representation
- Responsive design for data dashboards
π Problem-Solving Skills
- Debugging Python compatibility issues across versions
- Optimizing performance for large datasets
- Handling edge cases in data processing
- Creating intuitive UIs for complex data
π Domain Knowledge
- Understanding crime data patterns and seasonality
- Toronto neighbourhood geography and characteristics
- Public safety metrics and risk assessment
- Statistical significance in crime prediction
π Development Best Practices
- Version control with Git and GitHub
- Project structure and organization
- Documentation and README writing
- Error handling and user feedback
π Design Principles
- Glassmorphism and modern UI trends
- Accessibility in data visualization
- Color theory for risk representation
- Typography hierarchy for readability
What's next for MapMySafety
π Enhanced ML Models
- Deep Learning: Implement LSTM/RNN models for better time-series predictions
- Ensemble Methods: Combine multiple models for improved accuracy
- Feature Expansion: Add weather data, socioeconomic factors, events calendar
- Real-time Updates: Integrate with live Toronto Police data feeds
π User Features
- User Accounts: Save favorite neighbourhoods and custom alerts
- Email Notifications: Alert users about crime trends in their area
- Route Planning: Suggest safest routes between locations
- Mobile App: Native iOS/Android applications
- Voice Assistant: Integrate with Alexa/Google Home for hands-free queries
π Advanced Visualizations
- 3D Heatmaps: Interactive 3D crime density visualization
- Time-lapse Animations: Show crime evolution over time
- Comparative Analysis: Side-by-side neighbourhood comparisons
- Predictive Heatmaps: Show where crimes are likely to occur
π Community Features
- User Reports: Allow community-submitted safety observations
- Business Insights: Help businesses assess location safety
- Real Estate Integration: Partner with housing platforms
- Safety Score API: Provide data to third-party apps
π Expansion
- More Cities: Expand to Vancouver, Montreal, Calgary
- International: Support global cities with open crime data
- Multi-language: Support French, Spanish, Mandarin
- Accessibility: Enhanced screen reader support, high-contrast modes
π Data Enhancements
- Historical Trends: 20+ years of data for long-term analysis
- Demographic Correlation: Analyze correlations with census data
- Economic Impact: Study relationship between crime and local economy
- Policy Analysis: Track impact of safety initiatives
π Technical Improvements
- Performance: Implement caching and database optimization
- Scalability: Migrate to cloud infrastructure (AWS/Azure)
- Real-time: WebSocket updates for live crime data
- Testing: Comprehensive unit and integration tests
- CI/CD: Automated deployment pipeline
π Social Impact
- Partner with Toronto Police: Collaborate for data accuracy
- Community Outreach: Educational programs about data-driven safety
- Non-profit Support: Free access for community organizations
- Research Collaboration: Partner with universities for crime studies
Team members :- Divyanshi kashyap Vanshika and Saumya Jaiswal
Try It Out
Live Demo: [Coming Soon]
GitHub: https://github.com/Divkashyap29/MapMySafetyToronto
Video Demo:
Built With
- css3
- folium
- heatmap
- machine-learning
- numpy
- pandas
- react.js
- restful
- scikit-learn
- standardscaler
- uvicorn
Log in or sign up for Devpost to join the conversation.