Instructions to use ayanjawed/transitpulse-planning-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use ayanjawed/transitpulse-planning-model with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("ayanjawed/transitpulse-planning-model", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
|
Download README.md from ayanjawed/transitpulse-planning-model: direct link, hf CLI and curl.
- Browser
- Download file 4.27 kB
-
https://huggingface.co/ayanjawed/transitpulse-planning-model/resolve/main/README.md
- Command line
-
hf download hf://ayanjawed/transitpulse-planning-model/README.md
-
curl -L -o README.md https://huggingface.co/ayanjawed/transitpulse-planning-model/resolve/main/README.md
4.27 kB
| library_name: sklearn | |
| tags: | |
| - tabular-regression | |
| - time-series | |
| - transportation | |
| license: other | |
| # TransitPulse planning model | |
| Predicts **hourly bus ridership for one route** (riders per route-hour) from information known in advance: | |
| route, date, hour, schedule and weather. Built for transport planners as a CT-378 Machine Learning course project. | |
| - Live demo (Hugging Face Space, runs the model in the browser): https://huggingface.co/spaces/ayanjawed/TransitPulse | |
| - Live demo (Streamlit): https://ml-project-wuwhhjv3aqsnuxh5x5tdwi.streamlit.app/ | |
| - Code, data builder and notebooks: https://github.com/ayanmirza99/ML-Project | |
| ## Intended use | |
| - What-if planning for the 24 MTA bus routes it was trained on. It was trained on January to September 2025; | |
| the apps also accept later dates (up to 2027-06-30) with Open-Meteo forecast weather, but those are rough guesses, | |
| especially for March and October to December, which the model never saw. | |
| - **Not** for other routes or other cities (see Limitations). | |
| - The apps show each prediction with a ± 56 riders range (the validation MAE). | |
| ## Model | |
| `sklearn.pipeline.Pipeline`: one-hot encoding of `bus_route` and `borough`, then `HistGradientBoostingRegressor` | |
| (learning_rate 0.05, max_iter 500, max_leaf_nodes 63). Selected by validation MAE among models whose saved file is under 50 MB; | |
| a Random Forest was about as accurate but about 110 MB. | |
| Input columns: bus_route, borough, gtfs_n_stops, gtfs_max_stops_per_trip, sched_trips_hr, sched_headway_min, sched_trips_day, | |
| temperature_2m, precipitation, snowfall, wind_speed_10m, hour, day_of_week, is_weekend, hour_sin, hour_cos, is_am_peak, is_pm_peak, | |
| is_holiday, is_school_day. | |
| ## Data (three sources plus calendar) | |
| 1. **MTA Bus Hourly Ridership: Beginning 2025**, NY Open Data (dataset id `gxb3-akrn`), summed to one row per route per hour. | |
| Licence: the dataset page gives no licence information; it is covered by NY Open Data's terms of use. | |
| 2. **MTA GTFS static bus schedules** (mta.info/developers). A 2026 snapshot, not the 2025 service that produced the ridership. | |
| 3. **Open-Meteo historical weather** (New York City coordinates, one value per hour for the whole city). Licence: CC BY 4.0. Weather data by Open-Meteo.com. | |
| 4. US federal holidays (Python `holidays` package) and a hand-typed, approximate NYC school calendar. | |
| Eight two-week windows between January and September 2025, 24 routes, 64,512 route-hour rows. Missing hours are filled with 0 riders. | |
| Data are from New York because Karachi has no public passenger-count data. | |
| ## Evaluation | |
| Time-ordered split by whole days: train 2025-01-13 to 07-14, validation 07-15 to 09-04, test 09-05 to 09-28 (17 days, scored once). | |
| The final model is refit on train plus validation before testing. | |
| | | MAE (riders) | RMSE | R2 | | |
| |---|---|---|---| | |
| | Planning model (this model) | 65.4 | 113.3 | 0.92 | | |
| | Baseline: training average for the route, hour and weekday/weekend | 78.0 | 129.4 | 0.89 | | |
| The average route-hour in the test period has 450 riders, so the error is about 14.5%. | |
| A separate history model (uses recent ridership) reaches MAE 39.0 but needs recent data, so it is not deployed. | |
| Other checks: leave-one-window-out MAE 53.0 vs baseline 68.9; unseen routes MAE 111 vs baseline 132. | |
| ## Limitations | |
| - Only 24 routes and eight 2-week windows in one year; the test set is only 17 days, so small differences are not meaningful. | |
| - Some routes changed level during the year (Q58, Q10, Q65 about 35% lower; Q25 about 32% higher from summer). The model does not know about service changes; its error on these routes is about three times larger. | |
| - Weather helps a little, but partly because it hints at the season. It is not evidence that weather causes ridership changes. | |
| - Weather was one city-wide value, and the test used recorded (not forecast) weather, so real use will have higher error. | |
| - Schedule data is a 2026 snapshot; the school calendar is approximate; licence wording was not independently checked. | |
| - New York data only; no claim is made about Karachi. | |
| ## How to load | |
| ```python | |
| import joblib | |
| model = joblib.load("planning_model.joblib") # needs scikit-learn 1.9.1 | |
| ``` | |
| The input row must contain the columns listed above (see `app/features.py` in the project repository). | |