A Self-Attention Model for Next Location Prediction Based on Semantic Mining
Abstract
:1. Introduction
- We design semantic matching to effectively extract the semantic feature of each stay point. We then combine sematic matching with sequential pattern mining to result in richer semantic features.
- We use Node2vec and Time2vec, which consider the interaction of each location and the periodicity of the time series.
- We adopt Self-Attention to predict the user’s next trajectory for solving the problem with RNN (Recurrent Neural Network); the problem with RNN is that long-term memory is diminished with each transfer.
- We use Geolife dataset for our experiments. Based on experiment results, our method is better than a number of state-of-the-art methods.
2. Related Work
2.1. Location Prediction
2.2. Feature Extraction
3. Problem Statement
4. Proposed Method
4.1. System Framework
4.2. Input Features
- Trajectory data: The main data for predicting the user’s next location. The location is recorded every 1 to 5 s. Trajectory data record the living habits of users and provide clues for predicting the user’s next location.
- POI data: The POI data in the study area; each poi ∈ POI contains poi.ty, poi.lat and poi.lng.
- User Feature: User feature is the user ID . To personalize the prediction model, we consider the user feature ( is a one-hot vector whose dimension is the number of users ).
- Location Feature: We use stay grid to represent a location. Stay grid is one-hot vector, and the dimension of is determined by the number of grids that cover the study area which users have visited.
- Temporal Feature: Temporal feature reveals what time the information is in. Several methods usually perform a series of preprocessing on timestamps to extract temporal features for the next location prediction, such as converting timestamps into hour, day, week, month and season. In this paper, we convert timestamps into hours (1 to 24) to obtain temporal features t.
- Semantic Feature: Semantic feature is defined as the purpose of a user visiting a stay point. Some studies usually match a stay point to the nearest POI. In this paper, we introduce a semantic matching to extract semantic features; the architecture of semantic matching is shown in Figure 2.
- First, the algorithm searches for the nearest POI, then starts to calculate the of each .
- If c = home and = R, then is changed to home. Next, we calculate the reciprocal of the distance between and .
- If c = work and R, then is changed to workplace (because we think that POI that are not R is likely to be workplace). Next, we calculate the reciprocal of the distance between and .
- If home and c workplace, we directly calculate the reciprocal of the distance between and .
- We repeat , and when , the loop stops. We then normalize , ending the algorithm.
4.3. Prediction Model
4.3.1. Temporal Features Extractor
4.3.2. Location Features Extractor
4.3.3. Model Structure
5. Experimental Evaluation
5.1. Experimental Data and Setting
- Trajectory data: Our experiments are performed on the Geolife trajectory dataset. The Geolife dataset was obtained in the Geolife project by 182 users in Beijing over a period of more than 5 years (April 2007 to August 2012). Geolife is characterized by a series of timestamps; each timestamp contains a latitude and longitude, and the dataset contains records of 24,876,978 GPS points. In the stay point detection, the time threshold is 5 min, and the distance threshold is 200 m; we then achieve a total of 43,442 stay points. We remove users whose stay point records are less than 200, so the number of users is reduced from 182 to 50, and we will obtain 35,960 stay points. We then build a virtual grid in Beijing and map the coordinates of each stay point to the corresponding grid. The size of the grid is 500 × 500, there are 41,080 grid cells covering Beijing, the number of grid cells that the users have visited is 2211. When generating trajectory sequence, we set the time window to one week and the sliding window to 10. Finally, we obtain 23,775 trajectory sequences. Further details of the preprocessed dataset is shown in Table 2.
- POI data: We obtain the POI data of Beijing from the Tencent Web Service API. They provide detailed POI information such as coordinates, address, ID, name, phone number, type, etc. The Tencent Web Service API divides POIs into 18 main categories, the statistical distribution of which is shown in Figure 9. Therefore, we can calculate the semantic feature vector of each stay point based on these 18 types. In Tencent Maps, “Address” represents natural place names, road names, administrative place names and similar categories. This category does not conflict with other types of POIs.
5.2. Internal Experiment
5.2.1. Time Interval
5.2.2. Sliding Window
5.2.3. Location Feature
5.2.4. Temporal Feature
5.2.5. Semantic Feature
- Comparing SM* with CD: The improvement rate of SM* reaches 15% in TOP@1 (the model only considers semantic features). This shows that if the POI distribution around the stay point is considered, the accuracy can be effectively improved.
- Comparing SM with CD: The improvement rate of SM reaches 45% in TOP@1 (the model only considers semantic features). SM uses sequential pattern mining to compute semantic feature vectors, so that the prediction model can more accurately capture the intent of user activities and achieve better performance.
5.2.6. Prediction Model
5.2.7. User Feature
5.3. External Experiment
- SERM [12]: SERM jointly learns the embedding of various features (location, time, semantic and user) and uses LSTM to predict the next location.
- MSSRM [3]: MSSRM jointly learns various features (user, location and time), uses Node2vec embedding to learn location features and uses Time2vec to learn time features. LSTM is adopted to capture long short-term spatiotemporal dependencies, and Self-Attention is introduced to distinguish each location in different contexts.
5.3.1. Comparison of Different Methods
5.3.2. Comparison of Different Methods
5.3.3. Comparison of Different Sliding Window Sizes
5.3.4. Comparison of Different Methods on Weekdays and Weekends
5.4. Visualization of Location Prediction Results
6. Conclusions and Future Work
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Xu, M.; Han, J. Next Location Recommendation Based on Semantic-Behavior Prediction. In Proceedings of the 5th International Conference on Big Data and Computing, Chengdu, China, 28–30 May 2020; pp. 65–73. [Google Scholar]
- Feng, J.; Li, Y.; Yang, Z.; Qiu, Q.; Jin, D. Predicting Human Mobility with Semantic Motivation via Multi-Task Attentional Recurrent Networks. IEEE Trans. Knowl. Data Eng. 2022, 34, 2360–2374. [Google Scholar] [CrossRef]
- Wen, S.; Zhang, X.; Cao, R.; Li, B.; Li, Y. MSSRM: A Multi-Embedding Based Self-Attention Spatio-Temporal Recurrent Model for Human Mobility Prediction. Hum.-Centric Comput. Inf. Sci. 2021, 11, 37. [Google Scholar] [CrossRef]
- Fernandes, R.; D’Souza GL, R. A New Approach to Predict User Mobility Using Semantic Analysis and Machine Learning. J. Med. Syst. 2017, 41, 188. [Google Scholar] [CrossRef] [PubMed]
- Jiang, J.; Pan, C.; Liu, H.; Yang, G. Predicting Human Mobility Based on Location Data Modeled by Markov Chains. In Proceedings of the IEEE Fourth International Conference on Ubiquitous Positioning, Indoor Navigation and Location Based Services, Shanghai, China, 3–4 November 2016; pp. 145–151. [Google Scholar]
- Xia, Y.; Gong, Y.; Zhang, X.; Bae, H.Y. Location Prediction Based on Variable-order Markov Model and User’s Spatio-Temporal Rule. In Proceedings of the IEEE Conference on Information and Communication Technology Convergence, Jeju Island, Republic of Korea, 17–19 October 2018; pp. 37–40. [Google Scholar]
- Xia, L.; Huang, Q.; Wu, D. Decision Tree-based Contextual Location Prediction from Mobile Device Logs. Mob. Inf. Syst. 2018, 2018, 1852861. [Google Scholar] [CrossRef]
- Al-Molegi, A.; Jabreel, M.; Martínez-Ballesté, A. Move, Attend and Predict: An Attention-Based Neural Model for People’s Movement Prediction. Pattern Recognit. Lett. 2018, 112, 34–40. [Google Scholar] [CrossRef]
- Su, L.; Li, L. Trajectory Prediction Based on Machine Learning. IOP Conf. Ser. Mater. Sci. Eng. 2020, 790, 012032. [Google Scholar] [CrossRef]
- Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, L.; Polosukhin, I. Attention Is All You Need. In Proceedings of the Advances in Neural Information Processing Systems, Long Beach, CA, USA, 4–9 December 2017; pp. 5998–6008. [Google Scholar]
- Wang, S.; Li, A.; Xie, S.; Li, W.; Wang, B.; Yao, S.; Asif, M. A Spatial-Temporal Self-Attention Network (STSAN) for Location Prediction. Complexity 2021, 2021, 6692313. [Google Scholar] [CrossRef]
- Yao, D.; Zhang, C.; Huang, J.; Bi, J. SERM: A Recurrent Model for Next Location Prediction in Semantic Trajectories. In Proceedings of the ACM on Conference on Information and Knowledge Management, Singapore, 6–10 November 2017; pp. 2411–2414. [Google Scholar]
- Zhang, X.; Li, B.; Song, C.; Huang, Z.; Li, Y. SASRM: A Semantic and Attention Spatio-Temporal Recurrent Model for Next Location Prediction. In Proceedings of the IEEE International Joint Conference on Neural Networks, Glasgow, UK, 19–24 July 2020; pp. 1–8. [Google Scholar]
- Ying, J.J.C.; Lee, W.C.; Weng, T.C.; Tseng, V.S. Semantic Trajectory Mining for Location Prediction. In Proceedings of the ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems, Chicago, IL, USA, 1–4 November 2011; pp. 34–43. [Google Scholar]
- Mikolov, T.; Chen, K.; Corrado, G.; Dean, J. Efficient Estimation of Word Representations in Vector Space. arXiv 2013, arXiv:1301.3781. [Google Scholar]
- Sassi, A.; Brahimi, M.; Bechkit, W.; Bachir, A. Location Embedding and Deep Convolutional Neural Networks for Next Location Prediction. In Proceedings of the IEEE 44th LCN Symposium on Emerging Topics in Networking, Osnabrück, Germany, 14–17 October 2019; pp. 149–157. [Google Scholar]
- Grover, A.; Leskovec, J. Node2vec: Scalable Feature Learning for Networks. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, San Francisco, CA, USA, 13–17 August 2016; pp. 855–864. [Google Scholar]
- Xu, S.; Cao, J.; Legg, P.; Liu, B.; Li, S. Venue2vec: An Efficient Embedding Model for Fine-Grained User Location Prediction in Geo-Social Networks. IEEE Syst. J. 2019, 14, 1740–1751. [Google Scholar] [CrossRef]
- Chen, M.; Zuo, Y.; Jia, X.; Liu, Y.; Yu, X.; Zheng, K. CEM: A Convolutional Embedding Model for Predicting Next Locations. IEEE Trans. Intell. Transp. Syst. 2020, 23, 3349–3358. [Google Scholar] [CrossRef]
- Lu, E.H.C.; Lin, Z.Q. Rental Prediction in Bicycle-Sharing System Using Recurrent Neural Network. IEEE Access 2020, 8, 92262–92274. [Google Scholar] [CrossRef]
- Kazemi, S.M.; Goel, R.; Eghbali, S.; Ramanan, J.; Sahota, J.; Thakur, S.; Wu, S.; Smyth, C.; Poupart, P.; Brubaker, M. Time2vec: Learning A Vector Representation of Time. arXiv 2019, arXiv:1907.05321. [Google Scholar]
- Xie, M.; Yin, H.; Wang, H.; Xu, F.; Chen, W.; Wang, S. Learning Graph-based POI Embedding for Location-Based Recommendation. In Proceedings of the 25th ACM International Conference on Information and Knowledge Management, Indianapolis, IN, USA, 24–28 October 2016; pp. 15–24. [Google Scholar]
- Cao, H.; Xu, F.; Sankaranarayanan, J.; Li, Y.; Samet, H. Habit2vec: Trajectory Semantic Embedding for Living Pattern Recognition in Population. IEEE Trans. Mob. Comput. 2019, 19, 1096–1108. [Google Scholar] [CrossRef]
- Ye, Y.; Zheng, Y.; Chen, Y.; Feng, J.; Xie, X. Mining Individual Life Pattern Based on Location History. In Proceedings of the IEEE Tenth International Conference on Mobile Data Management: Systems, Services, and Middleware, Taipei, Taiwan, 18–20 May 2009; pp. 1–10. [Google Scholar]
- Chen, C.C.; Chiang, M.F. Trajectory Pattern Mining: Exploring Semantic and Time Information. In Proceedings of the IEEE Conference on Technologies and Applications of Artificial Intelligence, Hsinchu, Taiwan, 25–27 November 2016; pp. 130–137. [Google Scholar]
- Zheng, Y.; Xie, X.; Ma, W.Y. GeoLife: A Collaborative Social Networking Service Among User, Location and Trajectory. IEEE Data Eng. Bull. 2010, 33, 32–39. [Google Scholar]
Notation | Description |
---|---|
Trajectory, GPS point | |
User, set of users | |
Stay point, set of stay points | |
Latitude, longitude | |
Time of entering and leaving a stay point | |
POI, set of POIs | |
A type of POI, set of types | |
Semantics | |
Stay grid, set of stay grids |
Attribute | Value |
---|---|
City | Beijing City |
Duration | April 2007 to August 2012 |
Users (raw/processed) | 182/50 |
GPS points (raw) | 24,876,978 |
Stay points (raw/processed) | 43,442/35,960 |
Grid (raw/the users have been) | 41,080/2211 |
Stay grid (processed) | 35,960 |
Trajectory sequence (processed) | 24,056 |
Trajectory sequence/users(processed) | 475 |
Experiment | Method | Default |
---|---|---|
Sliding window | Sliding window size = {1, 2, …, 15} | 10 |
Location feature | None/Full connection/Word2vec/Node2vec | Node2vec |
Temporal feature | None/Hour/Sin and cos/Time2vec | Time2vec |
Semantic feature | Semantic matching k = {1, 2, …, 100} | k = 74 |
Closest distance/Semantic matching (not considering home and workplace)/Semantic matching | Semantic Matching | |
User feature | Remove User ID/Has User ID | Has User ID |
Prediction model | LSTM/BiLSTM/Self-Attention | Self-Attention |
Method | Top@1 | Top@5 | Top@10 | Top@15 |
---|---|---|---|---|
Same time interval | 19.88 0.17 | 46.55 0.45 | 54.68 0.57 | 58.71 0.56 |
Without time interval | 21.56 0.45 | 49.59 0.55 | 58.93 0.42 | 63.05 0.52 |
Method | Top@1 | Top@5 | Top@10 | Top@15 |
---|---|---|---|---|
None | 18.320.22 | 43.070.51 | 53.230.31 | 57.890.33 |
FC | 21.310.42 | 48.890.55 | 58.240.48 | 62.340.38 |
Word2vec | 21.370.52 | 48.780.56 | 58.280.37 | 62.310.40 |
Node2vec | 21.56 0.45 | 49.59 0.55 | 58.93 0.42 | 63.05 0.52 |
Method | Top@1 | Top@5 | Top@10 | Top@15 |
---|---|---|---|---|
None | 19.740.39 | 47.820.49 | 56.830.36 | 60.730.50 |
Hour | 20.410.44 | 47.860.74 | 56.900.64 | 60.940.53 |
Sin and cos | 20.780.43 | 47.660.55 | 56.670.53 | 60.620.56 |
Time2vec | 21.56 0.45 | 49.59 0.55 | 58.93 0.42 | 63.05 0.52 |
Method | Top@1 | Top@5 | Top@10 | Top@15 |
---|---|---|---|---|
CD | 8.060.32 | 21.540.27 | 30.080.33 | 35.150.28 |
SM* (Improvement Rate) | 9.270.72 (15.01%) | 28.320.74 (31.47%) | 37.470.79 (24.56%) | 42.170.72 (19.97%) |
SM (Improvement Rate) | 11.75 0.31 (45.78%) | 30.78 0.61 (42.89%) | 39.45 0.66 (31.15%) | 43.87 0.66 (24.80%) |
Method | Top@1 | Top@5 | Top@10 | Top@15 |
---|---|---|---|---|
None | 20.890.52 | 47.920.45 | 57.120.47 | 61.240.54 |
CD | 20.980.45 | 47.810.61 | 56.760.57 | 60.790.52 |
SM* | 21.400.25 | 48.580.49 | 58.110.60 | 62.250.63 |
SM | 21.56 0.45 | 49.59 0.55 | 58.93 0.42 | 63.05 0.52 |
Method | Top@1 | Top@5 | Top@10 | Top@15 |
---|---|---|---|---|
LSTM | 21.130.51 | 48.050.50 | 57.590.48 | 61.650.47 |
BiLSTM | 20.820.42 | 46.710.61 | 56.120.68 | 60.300.72 |
Attention | 21.56 0.45 | 49.59 0.55 | 58.93 0.42 | 63.05 0.52 |
Method | Top@1 | Top@5 | Top@10 | Top@15 |
---|---|---|---|---|
Remove User ID | 20.520.45 | 46.770.53 | 55.280.56 | 59.220.63 |
Retain User ID | 21.56 0.45 | 49.59 0.55 | 58.93 0.42 | 63.05 0.52 |
Method | Top@1 | Top@5 | Top@10 | Top@15 |
---|---|---|---|---|
SERM | 20.030.42 | 45.580.50 | 54.800.48 | 59.020.36 |
MSSRM | 21.030.43 | 46.930.41 | 55.880.30 | 60.000.35 |
Our Method | 21.56 0.45 | 49.59 0.55 | 58.93 0.42 | 63.05 0.52 |
Grid Size (m) | Method | Top@1 | Top@5 | Top@10 | Top@15 |
---|---|---|---|---|---|
300 × 300 | SERM | 13.820.61 | 34.930.48 | 44.220.57 | 48.710.47 |
MSSRM | 14.570.49 | 36.090.37 | 45.020.47 | 49.380.46 | |
Our Method | 15.60 0.37 | 39.23 0.35 | 48.45 0.51 | 52.94 0.30 | |
500 × 500 | SERM | 20.030.42 | 45.580.50 | 54.800.48 | 59.020.36 |
MSSRM | 21.030.43 | 46.930.41 | 55.880.30 | 60.000.35 | |
Our Method | 21.56 0.45 | 49.59 0.55 | 58.93 0.42 | 63.05 0.52 | |
700 × 700 | SERM | 28.890.42 | 55.360.31 | 62.980.44 | 66.790.52 |
MSSRM | 29.280.61 | 56.670.52 | 63.650.41 | 66.950.57 | |
Our Method | 29.92 0.50 | 58.15 0.39 | 65.04 0.47 | 68.47 0.45 |
Window Size | Method | Top@1 | Top@5 | Top@10 | Top@15 |
---|---|---|---|---|---|
7 | SERM | 0.45 | 0.66 | 0.65 | 0.71 |
MSSRM | 0.34 | 0.50 | 0.34 | 0.44 | |
Our Method | 0.51 | 0.27 | 0.30 | 0.47 | |
10 | SERM | 0.42 | 0.50 | 0.48 | 0.36 |
MSSRM | 0.43 | 0.41 | 0.30 | 0.35 | |
Our Method | 0.45 | 0.55 | 0.42 | 0.52 | |
13 | SERM | 0.63 | 0.75 | 0.72 | 0.88 |
MSSRM | 0.59 | 0.54 | 0.58 | 0.58 | |
Our Method | 0.49 | 0.50 | 0.54 | 0.49 |
Date | Method | Top@1 | Top@5 | Top@10 | Top@15 |
---|---|---|---|---|---|
Weekday | SERM | 0.45 | 0.72 | 0.60 | 0.61 |
MSSRM | 0.59 | 0.84 | 0.78 | 0.77 | |
Our Method | 0.51 | 0.83 | 0.79 | 0.76 | |
Weekend | SERM | 1.19 | 1.54 | 1.19 | 0.94 |
MSSRM | 1.36 | 1.18 | 1.19 | 1.08 | |
Our Method | 0.82 | 1.19 | 0.76 | 0.66 | |
Cross | SERM | 0.49 | 0.55 | 0.74 | 0.48 |
MSSRM | 0.53 | 0.50 | 0.62 | 0.59 | |
Our Method | 0.78 | 0.84 | 0.95 | 0.70 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Lu, E.H.-C.; Lin, Y.-R. A Self-Attention Model for Next Location Prediction Based on Semantic Mining. ISPRS Int. J. Geo-Inf. 2023, 12, 420. https://doi.org/10.3390/ijgi12100420
Lu EH-C, Lin Y-R. A Self-Attention Model for Next Location Prediction Based on Semantic Mining. ISPRS International Journal of Geo-Information. 2023; 12(10):420. https://doi.org/10.3390/ijgi12100420
Chicago/Turabian StyleLu, Eric Hsueh-Chan, and You-Ru Lin. 2023. "A Self-Attention Model for Next Location Prediction Based on Semantic Mining" ISPRS International Journal of Geo-Information 12, no. 10: 420. https://doi.org/10.3390/ijgi12100420
APA StyleLu, E. H.-C., & Lin, Y.-R. (2023). A Self-Attention Model for Next Location Prediction Based on Semantic Mining. ISPRS International Journal of Geo-Information, 12(10), 420. https://doi.org/10.3390/ijgi12100420