Organizations: University of California San Diego, CA, USA · McGill University Mila - Quebec AI Institute Montréal, QC, Canada · University of Pennsylvania Philadelphia, PA, USA · Duke Kunshan University Kunshan, Jiangsu, China
Transportation mode detection is an important topic within GeoAI and transportation research. In this study, we introduce SpeedTransformer, a novel Transformer-based model that relies solely on speed inputs to infer transportation modes from dense smartphone GPS trajectories. In benchmark experiments, SpeedTransformer outperformed traditional deep learning models, such as the Long Short-Term Memory (LSTM) network. Moreover, the model demonstrated strong flexibility in transfer learning, achieving high accuracy across geographical regions after fine-tuning with small datasets. Finally, we deployed the model in a real-world experiment, where it consistently outperformed baseline models under complex built environments and high data uncertainty. These findings suggest that Transformer architectures, when combined with dense GPS trajectories, hold substantial potential for advancing transportation mode detection and broader mobility-related research.
Figures & tables
Figure 1: Transformer architecture
Figure 2: Data Pre-Processing
Mode
Data Points
Unique Trips
MOBIS
Geolife
MOBIS
Geolife
Bike
4,251,028
746,098
40,171
1,555
Bus
4,606,409
1,061,196
74,324
1,847
Car
88,965,473
627,047
542,078
1,293
Train
8,379,962
788,250
130,964
772
Walk
38,463,266
1,215,054
743,425
3,960
Table 1: Comparison of MOBIS and Geolife Datasets
Model
Test Acc. (%)
SpeedTransformer (Ours)
95.97
Deep-ViT [ Ribeiro et al., 2024 ]
92.96
LSTM-based DNN [ Yu, 2020 ]
92.70
LSTM-Attention (Baseline)
92.40
CE-RCRF [ Zeng et al., 2023 ]
85.23
SECA [ Dabiri et al., 2020 ]
84.80
Table 2: Test Accuracy Comparison on Geolife (Ordered by Performance)
Figure 3: Validation accuracies over epochs for Geolife and MOBIS. The SpeedTransformer consistently converges faster and achieves higher overall accuracy than the LSTM-Attention baseline on both datasets.
Figure 4: Per class F1-Score for Geolife and MOBIS trainings using SpeedTransformer and LSTM. The SpeedTransformer consistently achieves better results than the LSTM-Attention across all classes on both datasets.
Mode
Deep-ViT
SpeedTransformer
Precision (%)
Recall (%)
Precision (%)
Recall (%)
Walk
95.04
96.12
96.72
99.90
Bike
93.79
91.40
98.54
95.45
Bus
89.68
91.13
98.14
95.49
Car
88.96
87.26
87.33
93.65
Train
90.00
79.41
95.66
92.93
Table 3: Validation Precision and Recall Comparison between Deep-ViT and SpeedTransformer on Geolife
Model
100 trips
200 trips
LSTM-Attention
75.47%
79.15%
SpeedTransformer
80.53%
86.13%
Table 4: Model Accuracy during Cross-Dataset Fine-Tuning from MOBIS to Small Geolife Subsets
Figure 5: Trip tracking interface in the CarbonClever application: (a) Trip initiation screen, where users start a new trip recording. (b) Active tracking screen showing real-time trip duration and status. (c) Trip completion and mode confirmation screen, where users select and verify the transportation mode. All interface texts are originally in Chinese.
Figure 6: Example of real-world GPS trajectories. The red line indicates the main route, with varying point density reflecting heterogeneous sampling frequencies. Purple circles mark signal interference and positioning noise.
Mode
Number of Data Points
Number of Unique Trips
Walk
28,985
100
Bus
32,547
259
Car
40,885
205
Bike
4,901
36
Train
1,505
49
Total
108,823
649
Table 5: Summary of the Mini-Program Dataset
Data Subset (%)
LSTM-Attention Acc. (%)
SpeedTransformer Acc. (%)
40% (251 trips)
88.79±2.15
90.27±2.04
50% (314 trips)
88.82±1.32
89.98±2.55
60% (377 trips)
89.34±1.86
90.40±2.17
70% (440 trips)
90.04±2.26
91.72±3.27
80% (502 trips)
89.30±2.52
90.11±4.54
Table 6: Fine-Tuning Accuracies of Models with Real-World Data Subsets (5-fold CV; mean ± std, % accuracy)
Appendix figures & tables17 assets
Supplementary material from the paper’s appendix.
Appendix
Mode
Min Speed (km/h)
Max Speed (km/h)
Bike
0.5
50
Bus
1.0
120
Car
3.0
180
Train
3.0
350
Walk
0.1
15
Appendix
Table A1: Speed Thresholds for Each Mode
Mode
Number of Data Points
Number of Unique Trips
Aerialway
109
7
Airplane
718,156
3,185
Bicycle
6,568,587
41,166
Bus
7,450,378
77,361
Car
160,348,026
553,259
Ferry
228
12
Appendix
Table A2: Summary of the MOBIS Dataset
Mode
Number of Data Points
Number of Unique Trips
Airplane
9,196
14
Bike
951,350
1,555
Boat
3,565
7
Bus
1,271,062
1,851
Car
512,939
782
Motorcycle
336
2
Appendix
Table A3: Summary of the Labeled Geolife Dataset
Figure F1: Effect of window size on test accuracy for the Geolife dataset. A window size of 200 provides the optimal balance between temporal context and computational efficiency, achieving the highest accuracy (95.97%).
W. Size
Test Acc. (%)
Test Loss
Run Name
20
77.58
0.5778
Geolife_ws20_lr2e-4_bs512_h8_d128_kv4_do0.1
50
84.86
0.4043
Geolife_ws50_lr2e-4_bs512_h8_d128_kv4_do0.1
100
92.07
0.2600
Geolife_ws100_lr2e-4_bs512_h8_d128_kv4_do0.1
200
95.97
0.1525
Geolife_ws200_lr2e-4_bs512_h8_d128_kv4_do0.1
300
95.04
0.1753
Geolife_ws300_lr2e-4_bs512_h8_d128_kv4_do0.1
400
94.53
0.1703
Geolife_ws400_lr2e-4_bs256_h8_d128_kv4_do0.1
Appendix
Table F12: Test accuracy and loss across different window sizes (Geolife dataset).
Figure G2: Transformer architecture for transportation mode classification.
Figure G3: Two GPS speed sequences share the same multiset of speeds but in different orders. Without position information the embeddings for repeated values (e.g., 7.8m/s ) are identical. With positional encoding we form zt=E(vt)+P(t) , allowing attention to model order-dependent patterns.
Model
Training Setup
Bike
Bus
Car
Train
Walk
LSTM
Geolife
0.92
0.86
0.86
0.92
0.99
MOBIS
0.61
0.84
0.99
0.28
0.99
MOBIS → Geolife
0.59
0.84
0.57
0.79
0.72
MOBIS → Mini-Program
0.39
0.69
0.93
0.79
0.86
Transformer
Geolife
0.93
0.96
0.92
0.87
0.99
MOBIS
0.78
0.88
0.98
0.43
0.99
Appendix
Table G13: Per-class accuracy (recall) of LSTM and Transformer models across datasets. Each model was trained on Geolife and MOBIS, and fine-tuned from MOBIS to Geolife and Mini-Program datasets.
Rule
Threshold (m/s)
Description / Condition for Mode Assignment
walk_p95_max
≤3.0
Windows with 95th-percentile speed below 3.0 m/s are classified as walk .
bike_p95_max
≤8.0
Windows with 95th-percentile speed between 3.0–8.0 m/s are classified as bike .
road_p95_min
≥17.4 (18.0*)
Windows exceeding this threshold are treated as motorized road transport ( bus or car ).
rail_p95_min
≥27.5 (40.0*)
Windows with very high 95th-percentile speed are classified as rail .
stop_thresh
<0.5
Speeds below 0.5 m/s are considered “stopped” for computing stop ratio.
bus_stop_ratio_min
≥0.05
Within the motorized range, higher stop ratios indicate bus .
Appendix
Table H14: Calibrated heuristic rules for transportation mode classification. Thresholds are tuned separately for each dataset using the training split. *A different threshold was used for Geolife
Dataset
Mode
Precision
Recall
F1-score
Support
Accuracy
Geolife
Bike
0.2818
0.3584
0.3155
3,200
Bus
1.0000
0.0000
0.0000
4,863
Car
0.0530
0.0871
0.0659
2,251
Train
0.4256
0.9512
0.5881
4,119
Walk
0.9463
0.4856
0.6418
5,225
Macro Avg.
0.5413
0.3765
0.3223
Appendix
Table H15: Performance of the calibrated rule-based model on Geolife and MOBIS datasets.
Figure I4: GPU and memory utilization of the Transformer model during training.
Figure L5: Sampling Frequency Distribution
Model
Pre-proc.
Input
Attention
PosEnc.
Params
SpeedTransformer
Speed Calc.
1D Speed
GQA
RoPE
0.73M
Deep-ViT [ Ribeiro et al., 2024 ]
Image Gen.
2D Image
Vision MHA
Learnable
0.53M
TMD-BERT [ Drosouli et al., 2023 ]
Discretisation
Tokens
Bi-Directional MHA
Learnable
110M
Note: GQA: Grouped-Query Attention; MHA: Multi-Head Attention; RoPE: Rotary Positional Embeddings; Image Gen.: DeepInsight Transform; Params: approximate number of trainable parameters using the best configuration.
Appendix
Table M16: Architectural Comparison of Transformer-based Mobility Models
Figure N6: Confusion matrices for SpeedTransformer on the Geolife and MOBIS test sets. Values are raw counts; MOBIS exhibits stronger class imbalance, leading to larger absolute counts.
Figure N7: Per class F1-Score for Fine-tuning on Geolife and our real-world field experiment data using SpeedTransformer and LSTM. The SpeedTransformer consistently achieves better results than the LSTM-Attention across all classes in both tasks.
Figure O8: Sequence-level speed dynamics for two dominant train failure profiles. The low_speed_confusion profile shows relatively smooth, gradual ramps; the high_speed_confusion profile has higher variance with abrupt fluctuations and spikes. Shaded regions indicate the 25–75% interquartile range across sequences.
Figure O9: Distributional heterogeneity in train-class speed statistics. Mean speed and joint mean–std representations overlap substantially between correct and incorrect train windows, showing that simple aggregates cannot isolate the failure profiles ( low_speed_confusion vs high_speed_confusion ).