Skip to content

Nishu1717/Toronto_Smartcity_Insights

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ™οΈ Toronto Smart City Insights

A comprehensive data analytics platform for Toronto municipal datasets

Python 3.13 Streamlit License: MIT

πŸ“‹ Executive Summary

Toronto Smart City Insights is an advanced analytics platform that transforms raw municipal data into actionable insights for city planning and public safety. The platform integrates crime indicators, 311 service requests, and traffic data to provide comprehensive visualizations, temporal analysis, and correlation insights through an interactive Streamlit dashboard.

Key Value Propositions:

  • 🎯 Data-Driven Decision Making: Transform 30,000+ municipal records into actionable insights
  • πŸ“Š Interactive Analytics: Real-time filtering and visualization across multiple datasets
  • πŸ—ΊοΈ Geospatial Intelligence: Interactive maps with crime heatmaps, service request density, and traffic patterns
  • πŸ“ˆ Temporal Analysis: Identify seasonal patterns, trends, and correlations over time
  • πŸ“₯ Export Capabilities: Download filtered data and analysis results in multiple formats

🎯 Project Goals

Primary Objectives

  1. Integrate Municipal Data Sources: Combine crime, 311, and traffic datasets into a unified platform
  2. Enable Interactive Exploration: Provide intuitive tools for data exploration and analysis
  3. Generate Actionable Insights: Identify patterns and correlations for city planning decisions
  4. Ensure Data Quality: Implement robust cleaning and validation pipelines
  5. Facilitate Data Export: Enable stakeholders to download and use processed data

Target Audience

  • City Planners: Strategic resource allocation and policy development
  • Public Safety Officials: Crime pattern analysis and prevention strategies
  • Data Analysts: Municipal data exploration and research
  • Citizens & Researchers: Transparent access to city data and insights

πŸ“Š Datasets

Data Sources (Toronto Open Data Portal)

Dataset Records Time Period Key Metrics
Crime Indicators 9,785 2014-2019 Incident types, locations, temporal patterns
311 Service Requests 9,999 2023 Service categories, response times, neighbourhood distribution
Traffic Data 14,135 1997-2024 Volume counts, collision data, monitoring locations
Neighbourhood Boundaries 158 Current Spatial boundaries, demographic context

Data Quality Metrics

  • Overall Completeness: 93.4% across all datasets
  • Coordinate Coverage: 66.7% (Crime: 100%, Traffic: 100%, 311: 0%)
  • Temporal Coverage: 27-year span with varying density
  • Spatial Coverage: All 158 Toronto neighbourhoods represented

πŸ› οΈ Technology Stack

Core Technologies

  • Python 3.13: Latest language features and performance improvements
  • Streamlit: Interactive web application framework
  • Pandas & NumPy: Data manipulation and numerical computing
  • GeoPandas: Geospatial data processing and analysis
  • Plotly: Interactive visualizations and charts
  • Folium: Interactive web maps and geospatial visualization

Data Processing

  • Data Cleaning: Automated pipelines with validation and standardization
  • Geospatial Processing: Coordinate validation, neighbourhood assignment
  • Temporal Analysis: Time series processing and pattern detection
  • Statistical Analysis: Correlation analysis with significance testing

Visualization & Export

  • Interactive Maps: Multi-layer maps with toggle controls
  • Statistical Charts: Temporal trends, correlations, and distributions
  • Export Formats: CSV, JSON, Excel, Parquet with metadata
  • Real-time Filtering: Dynamic data exploration capabilities

πŸš€ Quick Start

Prerequisites

  • Python 3.13 or higher
  • Git for version control
  • 4GB+ RAM recommended for large dataset processing

Installation

  1. Clone the Repository

    git clone <repository-url>
    cd smart-city-insights
  2. Set Up Virtual Environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install Dependencies

    # Fix NumPy 2.x compatibility (if needed)
    python fix_numpy_compatibility.py
    
    # OR install manually
    pip install 'numpy>=1.24.0,<2.0.0'
    pip install -r requirements.txt
    pip install -r dashboard/requirements.txt
  4. Run Data Processing Pipeline

    python src/run_full_cleaning.py
    python src/run_comprehensive_eda.py
  5. Launch Dashboard

    python launch_dashboard.py
    # OR
    streamlit run dashboard/app.py
  6. Access Application

    • Open browser to http://localhost:8501
    • Navigate through the 5 dashboard tabs
    • Use sidebar filters to explore data

πŸ“± Dashboard Features

🏠 Overview Tab

  • KPI Metrics: Total incidents, requests, and monitoring points
  • Temporal Trends: Monthly patterns across all datasets
  • Neighbourhood Analysis: Top areas by incident type
  • Correlation Summary: Cross-dataset relationships

πŸ—ΊοΈ Spatial View Tab

  • Interactive Maps: Multi-layer visualization with toggle controls
  • Crime Heatmaps: Density visualization of incident locations
  • 311 Density Maps: Service request choropleth by neighbourhood
  • Traffic Hotspots: Monitoring locations with volume indicators
  • Spatial Statistics: Coverage metrics and data quality indicators

πŸ“ˆ Temporal Trends Tab

  • Monthly Analysis: Incident patterns over time
  • Seasonal Patterns: Spring, Summer, Fall, Winter distributions
  • Weekday Analysis: Day-of-week incident patterns
  • Hourly Patterns: Time-of-day analysis (when available)
  • Chart Export: Multiple formats (PNG, HTML, SVG, PDF)

πŸ”— Correlation Explorer Tab

  • Neighbourhood Correlations: Statistical relationships between datasets
  • Temporal Correlations: Time-series correlation analysis
  • Cross-Dataset Analysis: 311 vs Crime relationship analysis
  • Statistical Testing: P-value calculation and significance assessment
  • Custom Analysis: User-defined dataset pairs and aggregation methods

πŸ“₯ Data Export Tab

  • Filtered Datasets: Apply filters and export subsets
  • Analysis Results: Download correlation matrices and insights
  • Multiple Formats: CSV, JSON, Excel, Parquet support
  • Metadata Inclusion: Timestamps and provenance tracking
  • Real-time Preview: Data filtering with immediate feedback

πŸ” Key Findings & Insights

Temporal Patterns

  • Crime Indicators: Peak activity varies by neighbourhood and season
  • 311 Requests: Higher volume during business hours and weekdays
  • Traffic Data: Consistent monitoring with volume-based patterns

Spatial Patterns

  • Crime Hotspots: Concentrated in specific neighbourhoods with identifiable patterns
  • Service Requests: Distributed across city with neighbourhood-specific needs
  • Traffic Monitoring: Comprehensive coverage with volume-based prioritization

Cross-Dataset Correlations

  • Crime vs Traffic: Moderate negative correlation (-0.592) at neighbourhood level
  • 311 vs Crime: Weak correlation with statistical analysis available
  • Temporal Alignment: Seasonal patterns vary across datasets

Data Quality Insights

  • Coordinate Completeness: Crime and Traffic data have full geospatial coverage
  • Temporal Coverage: Varying time periods require careful analysis alignment
  • Neighbourhood Assignment: 100% coverage for spatial analysis capabilities

πŸ“ˆ Business Impact

For City Planners

  • Resource Allocation: Data-driven deployment of services and personnel
  • Policy Development: Evidence-based policy creation using historical patterns
  • Performance Monitoring: Track service delivery and public safety metrics
  • Budget Planning: Optimize spending based on neighbourhood-specific needs

For Public Safety

  • Crime Prevention: Identify high-risk areas and temporal patterns
  • Response Optimization: Improve emergency response based on historical data
  • Community Engagement: Transparent data sharing with residents
  • Trend Analysis: Monitor long-term safety improvements

For Data Teams

  • Automated Processing: Scalable pipelines for ongoing data integration
  • Quality Assurance: Comprehensive validation and cleaning procedures
  • Export Capabilities: Flexible data access for downstream analysis
  • Visualization Tools: Ready-to-use charts and maps for reporting

πŸ—οΈ Project Structure

smart-city-insights/
β”œβ”€β”€ πŸ“ data_raw/                    # Original datasets from Toronto Open Data
β”œβ”€β”€ πŸ“ data_cleaned/                # Processed and validated datasets
β”‚   β”œβ”€β”€ πŸ“ maps/                   # Generated interactive maps
β”‚   β”œβ”€β”€ πŸ“ plots/                  # Analysis visualizations
β”‚   └── πŸ“„ analysis_insights.json  # Comprehensive analysis results
β”œβ”€β”€ πŸ“ src/                        # Core processing modules
β”‚   β”œβ”€β”€ πŸ“„ data_cleaner.py         # Data cleaning and validation
β”‚   β”œβ”€β”€ πŸ“„ geo_processor.py        # Geospatial processing
β”‚   β”œβ”€β”€ πŸ“„ analysis_engine.py      # Statistical analysis
β”‚   β”œβ”€β”€ πŸ“„ mapping_engine.py       # Interactive map generation
β”‚   └── πŸ“„ test_*.py              # Comprehensive test suite
β”œβ”€β”€ πŸ“ dashboard/                  # Streamlit web application
β”‚   β”œβ”€β”€ πŸ“„ app.py                 # Main dashboard application
β”‚   β”œβ”€β”€ πŸ“„ spatial_components.py  # Map and spatial visualizations
β”‚   β”œβ”€β”€ πŸ“„ temporal_components.py # Time series analysis
β”‚   β”œβ”€β”€ πŸ“„ correlation_components.py # Statistical analysis
β”‚   └── πŸ“„ export_components.py   # Data export functionality
β”œβ”€β”€ πŸ“ notebooks/                 # Jupyter analysis notebooks
β”‚   β”œβ”€β”€ πŸ“„ 01_data_cleaning_comprehensive.ipynb
β”‚   β”œβ”€β”€ πŸ“„ 02_geospatial_mapping.ipynb
β”‚   └── πŸ“„ 03_comprehensive_eda.ipynb
└── πŸ“„ requirements.txt           # Python dependencies

πŸ§ͺ Testing & Quality Assurance

Comprehensive Test Suite

  • Data Processing Tests: Validation of cleaning and transformation pipelines
  • Geospatial Tests: Coordinate validation and neighbourhood assignment
  • Analysis Tests: Statistical computation and correlation analysis
  • Dashboard Tests: UI components and interactive functionality
  • Export Tests: File format generation and data integrity

Quality Metrics

  • Test Coverage: 100% of core functionality tested
  • Data Validation: Multi-stage validation with error reporting
  • Performance Testing: Optimized for datasets up to 50,000 records
  • Cross-Platform: Tested on macOS, Windows, and Linux environments

πŸš€ Deployment Options

Local Development

# Quick start for development
python launch_dashboard.py

Cloud Deployment (Streamlit Cloud)

  1. Push to GitHub: Ensure all code is committed and pushed
  2. Connect Repository: Link GitHub repo to Streamlit Cloud
  3. Configure Settings: Set Python version to 3.13
  4. Deploy: Automatic deployment with requirements.txt
  5. Custom Domain: Optional custom domain configuration

Docker Deployment

# Dockerfile example (create as needed)
FROM python:3.13-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8501
CMD ["streamlit", "run", "dashboard/app.py"]

Environment Variables

# Optional configuration
STREAMLIT_SERVER_PORT=8501
STREAMLIT_SERVER_ADDRESS=0.0.0.0
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false

πŸ“š Documentation

User Guides

  • Dashboard User Guide: Complete walkthrough of all features
  • Data Export Guide: Instructions for downloading and using data
  • Analysis Methodology: Statistical methods and interpretation
  • Troubleshooting Guide: Common issues and solutions

Technical Documentation

  • API Reference: Function and class documentation
  • Data Schema: Dataset structure and field definitions
  • Processing Pipeline: Step-by-step data transformation process
  • Deployment Guide: Production deployment instructions

Research & Analysis

  • Methodology Report: Statistical approaches and validation methods
  • Data Quality Report: Completeness, accuracy, and coverage analysis
  • Performance Benchmarks: Processing times and optimization results
  • Future Enhancements: Roadmap for additional features

🀝 Contributing

Development Setup

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Run tests (python -m pytest src/test_*.py)
  4. Commit changes (git commit -m 'Add amazing feature')
  5. Push to branch (git push origin feature/amazing-feature)
  6. Open Pull Request

Code Standards

  • Python Style: Follow PEP 8 with Black formatting
  • Documentation: Comprehensive docstrings for all functions
  • Testing: Unit tests for all new functionality
  • Type Hints: Use type annotations for better code clarity

πŸ“„ License & Attribution

License

This project is licensed under the MIT License - see the LICENSE file for details.

Data Attribution

  • Toronto Open Data Portal: Primary data source for all municipal datasets
  • City of Toronto: Original data collection and maintenance
  • Statistics Canada: Neighbourhood boundary definitions
  • OpenStreetMap: Base map tiles for interactive visualizations

Acknowledgments

  • Toronto Open Data team for comprehensive municipal datasets
  • Streamlit community for excellent documentation and examples
  • Python geospatial community for robust processing libraries
  • Contributors and testers who helped improve the platform

πŸ“ž Contact & Support

Project Maintainer

  • Developer: [Your Name]
  • Email: [your.email@example.com]
  • LinkedIn: [Your LinkedIn Profile]
  • GitHub: [Your GitHub Profile]

Getting Help

  • Issues: Report bugs and request features via GitHub Issues
  • Discussions: Join community discussions for questions and ideas
  • Documentation: Comprehensive guides available in /docs folder
  • Email Support: Direct email for deployment and integration questions

Demo & Portfolio

  • Live Demo: [Streamlit Cloud URL when deployed]
  • Portfolio: [Your Portfolio Website]
  • Case Study: [Detailed project case study link]
  • Presentation: [Project presentation slides]

Built with ❀️ for Toronto's Smart City Initiative

Transforming municipal data into actionable insights for better city planning and public safety.

About

Interactive dashboard analyzing Toronto's municipal data - crime, 311 requests, and traffic patterns

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages