Antcar
commited on
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,3 +1,52 @@
|
|
| 1 |
-
---
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: keras
|
| 3 |
+
tags:
|
| 4 |
+
- transportation
|
| 5 |
+
- eta-prediction
|
| 6 |
+
- time-series
|
| 7 |
+
- regression
|
| 8 |
+
- hong-kong
|
| 9 |
+
- tabular
|
| 10 |
+
framework: tensorflow
|
| 11 |
+
license: mit
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# HK-TransitFlow-Net
|
| 15 |
+
|
| 16 |
+
A Deep Neural Network for predicting bus travel times in Hong Kong.
|
| 17 |
+
|
| 18 |
+
**Accuracy:** ~64 seconds Mean Absolute Error.
|
| 19 |
+
**Coverage:** Trained on KMB and CTB routes.
|
| 20 |
+
|
| 21 |
+
## Inputs
|
| 22 |
+
The model accepts 5 inputs. All numerical inputs should be shaped `(N, 1)`.
|
| 23 |
+
|
| 24 |
+
1. **`distance`** (Float): Physical distance of the segment/trip in meters.
|
| 25 |
+
2. **`num_stops`** (Float): Number of stops in the trip.
|
| 26 |
+
3. **`hour`** (Int): Hour of the day (0-23).
|
| 27 |
+
4. **`day_of_week`** (Int): 0=Sunday, 1=Monday, ..., 6=Saturday.
|
| 28 |
+
5. **`route_id`** (String): The specific GTFS Route ID (e.g., `968+1+...`). If unknown, use `"UNKNOWN"`.
|
| 29 |
+
|
| 30 |
+
## Usage (Python)
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
import tensorflow as tf
|
| 34 |
+
import numpy as np
|
| 35 |
+
from huggingface_hub import from_pretrained_keras
|
| 36 |
+
|
| 37 |
+
# 1. Download and Load
|
| 38 |
+
model = from_pretrained_keras("WheelsTransit/HK-TransitFlow-Net")
|
| 39 |
+
|
| 40 |
+
# 2. Prepare Data (Example: 5km trip, 8 stops, Mon 9AM)
|
| 41 |
+
# Note: Strings must be passed as tf.constant with dtype=tf.string
|
| 42 |
+
sample = {
|
| 43 |
+
'distance': np.array([[5000.0]], dtype='float32'),
|
| 44 |
+
'num_stops': np.array([[8]], dtype='float32'),
|
| 45 |
+
'hour': np.array([[9]], dtype='int32'),
|
| 46 |
+
'day_of_week': np.array([[1]], dtype='int32'),
|
| 47 |
+
'route_id': tf.constant([["UNKNOWN"]], dtype=tf.string)
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
# 3. Predict
|
| 51 |
+
prediction = model.predict(sample)
|
| 52 |
+
print(f"Predicted Duration: {prediction[0][0]:.2f} seconds")
|