A full-stack application designed to monitor, predict, and visualize transit delays in real-time. By leveraging machine learning and live data streaming, this tool identifies potential "cascading warnings" and grid anomalies before they impact the entire network.
- Real-Time Predictions: Continuously processes live transit data to predict station delays.
- Interactive Visualization: Dynamic Mapbox-powered dashboard showing station status across the San Francisco Bay Area.
- Anomaly Detection: Visual indicators for "Severe Delays" (>15 mins) with automated dashboard alerts.
- WebSocket Integration: Instant data broadcasting from the backend to the frontend for zero-latency updates.
- Frontend: React, Mapbox GL, React-Map-GL.
- Backend: Node.js, Express, WebSocket (
ws). - ML Engine: Python, XGBoost, Pandas, Scikit-learn.
The system consists of three primary components:
- ML Engine: A Python-based XGBoost regressor that predicts
actual_delaybased onhour_of_day,temp, andprev_delay. - Node.js Backend: Acts as the orchestrator, simulating live data streams and spawning Python processes to run predictions.
- React Frontend: A real-time map interface that receives updates via WebSockets and renders station health.
- Node.js (v16+)
- Python 3.8+
- Mapbox Access Token (Free tier)
cd ml-engine
pip install -r requirements.txt
python train.py # Generates the initial transit_model.jsoncd ../backend
npm installcd ../frontend
npm install- Start the Backend:
cd backend node server.js - Start the Frontend:
- Open
frontend/src/App.jsand replaceYOUR_MAPBOX_ACCESS_TOKENwith your token.
cd frontend npm start - Open
- View Results: Navigate to
http://localhost:3000. The map will begin updating every 3 seconds with new simulated station predictions.
The underlying model is an XGBoost Regressor trained on historical delay patterns. It considers environmental factors (temperature) and temporal factors (hour of day) to calculate the likelihood of a cascading delay.
- Input Features:
hour_of_day,temp,prev_delay. - Output:
predicted_delay_mins.