File size: 1,838 Bytes
06bff58
 
 
 
 
 
 
 
 
 
 
5a4dcbb
 
 
 
06bff58
 
 
 
 
 
 
 
 
94c468c
 
87713ee
 
 
 
06bff58
 
 
 
 
 
 
94c468c
06bff58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
library_name: keras
tags:
- transportation
- eta-prediction
- time-series
- regression
- hong-kong
- tabular
framework: tensorflow
license: mit
widget:
- text: "View Demo in Space"
  output:
    url: "https://huggingface.co/spaces/WheelsTransit/HK-TransitFlow-Demo"
---

# HK-TransitFlow-Net

A Deep Neural Network for predicting bus travel times in Hong Kong.

**Accuracy:** ~64 seconds Mean Absolute Error.  
**Coverage:** Trained on KMB and CTB routes.

The published version is mapped to used with [hk-bus-crawling](https://github.com/hkbus/hk-bus-crawling)

This is an open weight model, the source is not availible.

This is not Wheels Atlas, nor it is trained using the same way Atlas is.

## Inputs
The model accepts 5 inputs. All numerical inputs should be shaped `(N, 1)`.

1.  **`distance`** (Float): Physical distance of the segment/trip in meters.
2.  **`num_stops`** (Float): Number of stops in the trip.
3.  **`hour`** (Int): Hour of the day (0-23).
4.  **`day_of_week`** (Int): 0=Sunday, 1=Monday, ..., 6=Saturday.
5.  **`route_id`** (String): The specific Route ID. If unknown, use `"UNKNOWN"`.

## Usage (Python)

```python
import tensorflow as tf
import numpy as np
from huggingface_hub import from_pretrained_keras

# 1. Download and Load
model = from_pretrained_keras("WheelsTransit/HK-TransitFlow-Net")

# 2. Prepare Data (Example: 5km trip, 8 stops, Mon 9AM)
# Note: Strings must be passed as tf.constant with dtype=tf.string
sample = {
    'distance': np.array([[5000.0]], dtype='float32'), 
    'num_stops': np.array([[8]], dtype='float32'),
    'hour': np.array([[9]], dtype='int32'),
    'day_of_week': np.array([[1]], dtype='int32'),
    'route_id': tf.constant([["UNKNOWN"]], dtype=tf.string) 
}

# 3. Predict
prediction = model.predict(sample)
print(f"Predicted Duration: {prediction[0][0]:.2f} seconds")