An intelligent transit analytics platform that visualizes historical TTC bus delays and predicts future incidents using machine learning.
- Real-time heatmap of TTC bus delays across Toronto (2014-2024)
- Time-lapse slider to traverse 10+ years of historical data
- Color-coded markers showing delay severity (green → yellow → red)
- Machine learning model trained on 160,000+ delay incidents
- Predict delays for different incident scenarios (mechanical, collision, emergency, etc.)
- Route-specific forecasting with confidence intervals
- Top delayed routes and stations
- Delay patterns by hour, day of week, and season
- Incident type breakdown and trends
- Real-time statistics
- Autocomplete station search
- Route comparison tool (compare up to 3 routes side-by-side)
- Location-based predictions
- React + Vite - Fast, modern UI framework
- Tailwind CSS - Utility-first styling
- Mapbox GL JS - Interactive map visualization
- Recharts - Data visualization library
- FastAPI - High-performance Python API
- LightGBM - Gradient boosting ML model
- Pandas - Data processing
- Scikit-learn - Feature engineering & calibration
- 160K geocoded delays (2014-2024)
- TTC GTFS data for stop locations
- 100+ engineered features (temporal, spatial, route-based)
- Isotonic regression calibration for accurate predictions
- Docker - Containerized deployment
- Render.com - Cloud hosting
- Nginx - Static file serving
- Python 3.11+
- Node.js 18+
- Mapbox API token (free tier works)
cd machineLearning
pip install -r requirements.txt
python app.pyBackend runs at: http://localhost:8000
cd frontend
npm install
npm run devFrontend runs at: http://localhost:5173
Backend - No configuration needed!
Frontend - Create frontend/.env:
VITE_API_BASE_URL=http://localhost:8000
VITE_MAPBOX_TOKEN=your_mapbox_token_here- Temporal: Hour, day of week, season, rush hour indicators
- Spatial: Distance from downtown, location frequency, spatial clustering
- Route: Route frequency, numeric route encoding
- Cyclical encoding for time-based features
- Algorithm: LightGBM (gradient boosting)
- Training: 5-fold time-series cross-validation
- Calibration: Isotonic regression for prediction accuracy
- Features: 85+ engineered features
- Data: 160,079 historical incidents (2014-2024)
- ✅ Removed data leakage (incident/spatial averages)
- ✅ Added prediction calibration
- ✅ More accurate delay estimates
GET /healthGET /api/historical?start=2024-01-01T00:00:00&end=2024-01-02T00:00:00GET /api/predict?lat=43.7325&lon=-79.2631&route=36GET /api/analytics/overviewGET /api/stations/search?query=kennedy📖 Full API documentation: https://transight-backend.onrender.com/docs
docker build -f Dockerfile.backend -t transight-backend .
docker run -p 8000:8000 transight-backendcd frontend
docker build \
--build-arg VITE_API_BASE_URL=https://transight-backend.onrender.com \
--build-arg VITE_MAPBOX_TOKEN=your_token \
-t transight-frontend .
docker run -p 80:80 transight-frontendTransight/
├── machineLearning/ # Backend API & ML model
│ ├── app.py # FastAPI server
│ ├── predictor.py # ML prediction engine
│ ├── feature_engineering.py # Model training
│ ├── ttc_delay_model.joblib # Trained model (5.5 MB)
│ └── requirements.txt
├── frontend/ # React frontend
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── api/api.js # API client
│ │ └── App.jsx # Main app
│ ├── Dockerfile
│ └── nginx.conf
├── dataAnalysis/
│ └── geocoded_delays.parquet # Historical data (2.9 MB)
├── Dockerfile.backend # Backend container
├── render.yaml # Render deployment config
└── README.md
- Minimalist UI - Clean, Apple/Stripe-inspired design
- Performance First - Optimized API calls, lazy loading, caching
- Accessibility - Keyboard navigation, semantic HTML
- Responsive - Works on desktop, tablet, and mobile
- TTC Delay Data: 2014-2024 historical delays from TTC open data
- GTFS Stops: Station locations from TTC GTFS feed
- Geocoding: ~70% match rate using stop name matching
- 160,079 incidents geocoded and processed
- Real-time delay alerts via WebSocket
- User accounts & saved routes
- Mobile app (React Native)
- Integration with TTC NextBus API
- Predictive routing suggestions
- Multi-city support
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ by a transit enthusiast who's tired of being late
- TTC for providing open data
- Mapbox for beautiful maps
- Render.com for free hosting
- Claude for code assistance and debugging
- 🌐 Live Demo: https://transight.onrender.com
- 📚 API Docs: https://transight-backend.onrender.com/docs
- 🐛 Issues: GitHub Issues
Made for Torontonians, by Torontonians 🍁