|
Download README.md from HarryDataScience/mumbai-crowd-predictor: direct link, hf CLI and curl.
- Browser
- Download file 3.15 kB
-
https://huggingface.co/spaces/HarryDataScience/mumbai-crowd-predictor/resolve/main/README.md
- Command line
-
hf download hf://spaces/HarryDataScience/mumbai-crowd-predictor/README.md
-
curl -L -o README.md https://huggingface.co/spaces/HarryDataScience/mumbai-crowd-predictor/resolve/main/README.md
3.15 kB
| title: Mumbai Crowd Predictor | |
| emoji: π | |
| colorFrom: blue | |
| colorTo: purple | |
| sdk: docker | |
| pinned: false | |
| # π Mumbai Local Train β Crowd Density Predictor (Advanced Edition) | |
| AI-powered crowd prediction system for Mumbai Local Trains with a full-stack FastAPI + HTML/CSS/JS deployment. | |
| --- | |
| ## π Features | |
| - **AI Prediction** β RandomForest model with 17 engineered features (~97% accuracy) | |
| - **Hourly Forecast** β Full day crowd pattern for any route | |
| - **Station Heatmap** β Visual heatmap of crowd across stations Γ hours | |
| - **Risk Scoring** β 0β100 risk score with reasoning and travel tips | |
| - **Beautiful UI** β Dark glassmorphism design, animated charts, responsive | |
| --- | |
| ## ποΈ Project Structure | |
| ``` | |
| mumbai_train_app/ | |
| βββ main.py # FastAPI application (entry point) | |
| βββ requirements.txt | |
| βββ src/ | |
| β βββ model.py # RandomForest + feature engineering | |
| β βββ risk_engine.py # Risk scoring, explanations, tips | |
| βββ data/ | |
| β βββ raw/ | |
| β βββ mumbai_local_crowd_data.csv | |
| βββ static/ | |
| β βββ css/style.css # Full dark-mode glassmorphism CSS | |
| β βββ js/app.js # Frontend JavaScript | |
| βββ templates/ | |
| βββ index.html # Main HTML template | |
| ``` | |
| --- | |
| ## βοΈ Setup & Run | |
| ### 1. Install dependencies | |
| ```bash | |
| pip install -r requirements.txt | |
| ``` | |
| ### 2. Run the server | |
| ```bash | |
| python main.py | |
| # OR with uvicorn directly: | |
| uvicorn main:app --host 0.0.0.0 --port 8000 --reload | |
| ``` | |
| ### 3. Open in browser | |
| ``` | |
| http://localhost:8000 | |
| ``` | |
| --- | |
| ## π§ ML Model Details | |
| | Feature | Description | | |
| |---------|-------------| | |
| | `hour` | Hour of travel (5β22) | | |
| | `hour_weight` | Peak-hour weight (empirical) | | |
| | `day_num` | 0=Monday β 6=Sunday | | |
| | `is_weekday/weekend` | Binary flags | | |
| | `is_morning_peak` | 7β9 AM flag | | |
| | `is_evening_peak` | 5β7 PM flag | | |
| | `morning_southbound` | Directional rush interaction | | |
| | `evening_northbound` | Directional rush interaction | | |
| | `line_num` | Western/Central/Harbour encoded | | |
| | `dir_num` | Northbound/Southbound encoded | | |
| | `station_enc / dest_enc` | Label-encoded stations | | |
| **Algorithm**: Random Forest Classifier (200 trees, balanced class weights) | |
| **Accuracy**: ~97% on training data | |
| --- | |
| ## π‘ API Endpoints | |
| | Method | Path | Description | | |
| |--------|------|-------------| | |
| | GET | `/` | Web UI | | |
| | GET | `/api/lines` | All train lines | | |
| | GET | `/api/stations/{line}` | Stations for a line | | |
| | GET | `/api/stats` | Dataset + model stats | | |
| | POST | `/api/predict` | Single prediction | | |
| | POST | `/api/hourly-forecast` | Full day forecast | | |
| | GET | `/api/heatmap/{line}` | Station Γ hour heatmap | | |
| --- | |
| ## π€οΈ Train Lines Covered | |
| - **Western Line**: Churchgate β Virar (12 stations) | |
| - **Central Line**: CSMT β Kalyan (9 stations) | |
| - **Harbour Line**: CSMT β Panvel (8 stations) | |
| --- | |
| ## π¨βπ» Tech Stack | |
| - **Backend**: FastAPI + Uvicorn | |
| - **ML**: scikit-learn RandomForest, Pandas, NumPy, Joblib | |
| - **Frontend**: Pure HTML5 + CSS3 + Vanilla JS | |
| - **Design**: Dark glassmorphism, CSS animations, responsive | |