Next Article in Journal
Special Issue “Advances in Multi-Agent Systems”: Editorial
Next Article in Special Issue
Does Context Matter? Effective Deep Learning Approaches to Curb Fake News Dissemination on Social Media
Previous Article in Journal
Intelligent Recognition of Key Earthquake Emergency Chinese Information Based on the Optimized BERT-BiLSTM-CRF Algorithm
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Predicting Location of Tweets Using Machine Learning Approaches

1
Center for Artificial Intelligence (CAI), King Khalid University, Abha 61421, Saudi Arabia
2
College of Computer Science, King Khalid University, Abha 61421, Saudi Arabia
*
Author to whom correspondence should be addressed.
Appl. Sci. 2023, 13(5), 3025; https://doi.org/10.3390/app13053025
Submission received: 15 January 2023 / Revised: 20 February 2023 / Accepted: 23 February 2023 / Published: 26 February 2023
(This article belongs to the Special Issue Text Mining, Machine Learning, and Natural Language Processing)

Abstract

:
Twitter, one of the most popular microblogging platforms, has tens of millions of active users worldwide, generating hundreds of millions of posts every day. Twitter posts, referred to as “tweets”, the short and the noisy text, bring many challenges with them, such as in the case of some emergency or disaster. Predicting the location of these tweets is important for social, security, human rights, and business reasons and has raised noteworthy consideration lately. However, most Twitter users disable the geo-tagging feature, and their home locations are neither standardized nor accurate. In this study, we applied four machine learning techniques named Logistic Regression, Random Forest, Multinomial Naïve Bayes, and Support Vector Machine with and without the utilization of the geo-distance matrix for location prediction of a tweet using its textual content. Our extensive experiments on our vast collection of Arabic tweets From Saudi Arabia with different feature sets yielded promising results with 67% accuracy.

1. Introduction

Twitter is a microblogging service with over 368 million active users worldwide as of December 2022 [1]. Users share their thoughts, opinions, and ideas via short messages, or “tweets,” on various topics and events. One unique aspect of Twitter is that users can attach location information to their posts in the form of GPS coordinates [2].
The ability to attach location information to tweets has attracted attention from various research communities for its potential applications, such as real-time event detection [3,4,5], intelligent transportation systems [6], location-based recommendations [7,8], monitoring public health [9], and emergency and disaster analysis [10,11,12].
However, despite the usefulness of location data, only 1% of tweets in the Twitter stream have geographical information [13,14]. This limits the sample size for analysis, and the users who release their geographical information are not representative of the entire Twitter population [15]. Researchers have proposed new methods, such as named entity recognition [16,17,18,19] and analysis of Twitter networks [20] and user home locations from profiles [21,22], to analyze tweet content. However, these methods remain insufficient for applications that require precise geo-located data.
This challenge is even greater when considering tweets in the Arabic language. Only 0.5% of the 50 million Arabic tweets collected were geo-tagged, and only 15% of those tweets were tagged to a reasonable location [13,14]. This leaves only 0.08% of the collected 50 million Arabic tweets that can be used to build a learning model.
In this paper, we present several approaches for predicting the geographical location of tweets using Saudi Twitter content. Our research aims to determine the percentage of the most and least tagged tweets in comparison to the general locations in Saudi Arabia, taking into account various events and circumstances in the region. We extract text content from tweets and identify locations based on the geographical names mentioned. Our methods include multiple approaches for categorizing and evaluating the tweets, with the detection corresponding to the nature of the tweets and their references. The geographical data gathered have the potential for various applications and are effective for general time evaluation.

2. Related Works

In this section, we review the literature on the prediction of tweets’ geo-location. We aim to understand the general purposes behind these studies, the methods they have used to achieve their goals, and critically analyze their strengths, weaknesses, and limitations. Additionally, we compare our current approach with other research works and highlight its unique contributions.

2.1. The Purpose of Tweets’ Location Prediction

Geographical information can be attached to tweets in two ways [23]: (i) through accurate longitudinal and latitudinal coordinates when the user’s device location is enabled and (ii) through a suggested location from a list that can be interpreted as longitudinal and latitudinal coordinates. Despite this, less than 1% of tweets contain geographical information [13]. This highlights the significance of research on location prediction in social media, as geographical data opens up new opportunities for a wide range of real-time applications.
Twitter is a highly accessible platform for users to share their unexpected encounters with their online followers, causing it to be useful for real-time event detection [3,4,5]. Hashtags can be used in scenarios where people are tweeting about the same event using the same hashtag. Additionally, the precise location of a tweet is crucial in emergency management scenarios [10,12] as it enables safety enforcement personnel to perform prompt action. Inferring the ground truth of Twitter users is another area of interest [9,22,24,25,26].

2.2. Geo-Location Prediction Approaches

There are two main approaches to predict the location of a tweet based on its content, which are based on either using the content of the tweet alone or considering the geographical context.
The first approach clusters data based on the density of geo-tagged tweets in various areas. For instance, a study applied a Gaussian Mixture Model (GMM) to produce geographic density evaluations for all n-grams contained in the tweet, and the predicted position is provided by the weighted sum of all the density estimates [24,25]. Another study used an iterative GMM to predict the coordinate points of the geo-tagged tweets and found that an n-gram is geo-specific [27]. The center of the longest geo-specific n-gram is adopted as the predicted location if an ellipse can be built using the GMM that covers a predefined maximum area and contains a specific ratio of total tweets.
The second approach transforms the geographical space into a grid of predefined regions. Some studies have built a language model for each area to predict the location [28,29,30,31,32]. The likelihood of a tweet being generated in an area is determined based on its relevance to the geo-tagged tweets in the area. The closest distance is returned as the predicted location. For example, a study divided the earth’s geographical area into cells of about 111 km [32]. The researchers used multinomial naive Bayes (MNB) and Kullback–Leibler divergence functions to build the language model, including word counts as features. Another study used a Gaussian kernel instead of word counts to generate features [32].
This section provides a comprehensive overview of the related works in the field of tweet geo-location prediction. The importance of geographical information in tweets and the applications it enables is first explained.
The main approaches for geo-location prediction section then describes the two main approaches used for geo-location prediction, based on either the content of the tweet or the geographical context. The strengths and limitations of each approach are discussed.
Roller et al.’s [29] use of a Recurrent Neural Network (RNN) for their language model is a strength of their approach. RNNs are well suited to capture temporal information, which is important in this context because the geographical context of a tweet is dependent on the time it was posted. This temporal information can help to improve the accuracy of location predictions.
However, this approach also has limitations. As with the second approach in general, the accuracy of the predictions may be impacted by the size of the regions and the choice of the language model. Choosing a model that is well suited to the task at hand is crucial in achieving high accuracy.
Recent research by Mostafa et al. [33] and Mahajan and Mansotra [34] have also contributed to the field of tweet geo-location prediction. Mostafa et al. (2022) used a combination of geographical and text-based features to create their predictions, which helped to improve the accuracy of their results. In their study, the authors found that incorporating both geographical and text-based features improved the accuracy of location predictions compared to when only text-based features were used.
Mahajan and Mansotra (2021) used a deep learning approach to create their predictions. They found that their approach outperformed other existing methods, including those based on traditional machine learning algorithms. The authors concluded that deep learning approaches have the potential to significantly improve the accuracy of tweet geo-location predictions.
In comparison to these recent research works, our current approach takes into account the geographical context of a tweet and its content to create predictions. This multi-faceted approach helps to improve the accuracy of our predictions, as well as to better understand the underlying factors that contribute to the geographical information of a tweet. Additionally, we aim to incorporate elements of perplexity and burstiness into our approach, which will help to further improve the accuracy of our predictions by taking into account the context of the tweet and the patterns of usage on the platform.
Recent research works by Mostafa et al. (2022) and Mahajan and Mansotra (2021) are introduced, highlighting their contributions to the field.
The revised section compares the current approach with other research works and highlights its unique contributions. By considering both the geographical context and the content of a tweet, and incorporating elements of perplexity and burstiness, the current approach stands out as a comprehensive and innovative solution. Overall, the revised section provides a comprehensive and up-to-date overview of the field, which will help to contextualize the current approach and emphasize its strengths and unique contributions.

3. Data Collection and Preparation

This section will elaborate on how the data were collected and prepared in this study.

3.1. Data Collection

More than 50 million Arabic tweets were collected from trending hashtags in Saudi Arabia. The tweets covered a wide range of topics including: social events, such as large parties, sports events, festivals, accidents, and natural phenomena, such as storms, heavy rainfall, tornadoes, sandstorms, and earthquakes. Each tweet contained the following attributes (see Table 1): user’s ID, user’s name, the ground truth home location of the user (if any), the geo-tags of the tweet itself (if any), and the body of the tweet itself. The data lacked location information; both geo-tags and home location were mostly absent, except in 0.5% and 3.9% out of the collected tweets, respectively, (Table 2). The user home location contained the user-specified geographical location, which could be in the form of a city, country, or landmark name. It could also be a nickname, an imaginary place, or even an empty text.
Since the collected tweets concerned Saudi trends, we looked for tweets with geo-tags within Saudi Arabia. Only 1.9 million tweets among the total contained home location, and 253,673 tweets were geo-tagged. Table 2 summarizes the tweet statistics. The tweets from Saudi Arabia were clustered into 121 unique locations. However, some locations, as expected, consisted of more unique tweets than others. Therefore, several rebalancing steps were performed to relieve this imbalance. Some of these steps are discussed in this section, while others will be explained Section 3.2. The locations with less than a certain threshold of number of tweets corresponding to them were removed. We chose this threshold as 70. Therefore, each location with less than 70 unique tweets was removed. Furthermore, a location with tweets from less than five unique users was removed. This step left us with 30 distinct geo-tagged locations extracted from Google Maps API according to the latitudinal and longitudinal coordinates attached to the tweets (see Table 3). Therefore, several rebalancing steps were performed to relieve this imbalance.
Thus, the dataset documents now belonged to 30 classes as c = { 1 , 2 , . . . , 30 } , where the classes were assigned as shown in Table 3.

3.2. Data Cleansing

Twitter texts deviate from regular documents in many forms. First, they are short tweets with a maximum allowable length of 280 characters, which was 140 before 2017. Furthermore, Twitter messages can contain colloquial language, text in various dialects, shortened text (e.g., ‘ع’ for ‘على’ On, or ‘ي’ for ‘يا’ Vocative particle “O”) or even misspelled words. Furthermore, it allows users to socialize with other users in many ways. Retweeting others’ tweets is one way of socializing. Mentioning another user is also a way where users use the symbol “@” to mention someone else. Besides, users can add hashtags, consisting of the symbol “#” supported by a keyword, to specify the point of their tweet (e.g., موسم _الرياض# #Riyadh_ Season). Ultimately, Twitter documents can hold hyperlinks to external websites. However, these documents, when fetched from Twitter, are in raw noisy and fuzzy format. As we needed to extract tweet text, the documents might include a mixture of different data types, namely, words, numbers, hashtags, URLs, mentions, emojis images, and videos.
The cleansing process of Twitter documents involved the (i) tokenization of words; (ii) extraction of hashtags and user mentions; and (iii) elimination of stop-words, numbers, URLs, images, videos, symbolic characters, and emojis. This might be universal for all languages. However, Arabic language has extra characteristics, which might have introduced another level of ambiguity. Table 4 illustrates Arabic diacritics, which are usually added to each letter in the word. As they are optional, we eliminated them. However, some diacritics are not as ambiguous as the ones shown in Table 4. There are letters that Twitter users use interchangeably, which should not be the case in the Standard Arabic. For instance, the letter Alif can be written as Alif with Hamza ‘أ’ or as a plain Alif ‘ا’. Similarly, the letter Taa can be written as Taa Marbootah `ة’ or as Haa ‘هـ’ because Arabic words are commonly written in different formats for the same terms as indicated in Table 5. In this case, these letters are not always interchangeable. For example, the word ‘علي’ means the name “Ali” while the word ‘على’ means the preposition word “On” and is pronounced in Arabic “Ala”. Yet, due to the similarity in writing them, it is common on Twitter to use them interchangeably. Finally, data cleansing identified duplicate documents that were needed to be filtered out as well.

4. Methodology

In this study, we aimed to detect the respective locations of (Arabic) tweets using machine learning and natural language processing techniques. We conducted intensive experiments to achieve the state-of-the-art accuracy, where the flowchart is shown in Figure 1. Each experiment was designed to evaluate the predictability of certain features. We used three sets of features, namely, tweet text, user’s home location, and named entity in the tweet. Thus, different feature sets were utilized in different experiments. The tweet text was represented in several ways, which impacted model performance differently. Furthermore, the home location of the user was employed to improve the predictability. In the remainder of this section, we will describe our features and machine learning algorithms in details.

4.1. Location Prediction Using Tweet Text and Home Location

In the first experiment, we aimed to predict the geo-location of tweets based on the tweet text and the home location stated in the user’s profile. We generated text features using the TF-IDF method and the home location feature. The TF-IDF method calculates the importance of a word in a particular class by taking into account the frequency of the same word in other classes (see Equation (1)). This enables us to determine the significance of different words in terms of location prediction performance.
t f ( t i , c k ) = f c k ( t i ) j , k f c k ( t j )
i d f ( t i , c ) = log ( | c | | { c t i c : t i c t i } | )
where t f ( t i , c k ) is the term frequency of the word t i in class c k , which can be calculated by dividing the same term frequency f c k ( t i ) in that class by the total number of words in the class. i d f ( t i ) is the inverse document frequency. It can be calculated by the log of the total number of classes by the number of classes that contain the term t i .
t f - i d f ( t i , c k , c ) = t f ( t i , c k ) · i d f ( t i , c )
In addition to the tweet text, we also utilized the home location in this experiment. However, we acknowledge that the home location information can be noisy or even missing in many cases, as a large number of users may not state their real location. For instance, we encountered users who stated their home location as “Earth” or even “Milky Way”, causing the detection of their real location to be more challenging.

4.2. Location Prediction Using Tweet Text and Named Entity

In this experiment, we aimed to improve the location prediction performance by incorporating another feature: named entities. Named entities such as cities, airport names, and attractions were included in our feature set. We created a list of named entities in Saudi Arabia and, whenever we encountered one of these entities in the tweet text, it was considered as a feature (see Section 4.1). Our assumption was that people from the same city are more likely to mention the name of their city or a famous attraction in their tweets. The same text features from the previous experiment were used in this experiment. We also added the named entities as an additional feature to assess its impact on the prediction performance. The results of this experiment were compared with the results of the previous experiment to determine the effectiveness of adding named entities as a feature.

4.3. Location Prediction Using Tweet Text, Home Location, and Named Entity

After we evaluated the predictability of each two sets of features separately, we evaluated it by combining the three feature sets. We prepared and represented the features exactly as we did previously. This experiment was supposed to yield the best predictability performance compared with the previous ones due to consolidating the three sets of features together.

4.4. Model Building

We conducted this experiment by building four different machine learning models to predict the tweet location based on the aforementioned features. The models are well-known in the field and have been proven effective in supervised machine learning problems. The first algorithm is logistic regression (LR), which is simply a linear regression with binary mapping. The logistic function can be provided as:
f ( y ) = 1 1 + e y ,
where y is the linear regression function y = w x + b [35]. The second Algorithm is MNB. Due to its computational efficiency and proper performance in real-world problems, MNB is one of the most employed algorithms, especially in text classification problems [36]. In our MNB model, we assumed the data to have a multinomial distribution. Therefore, the MNB classifier was evaluated as follows:
p ( c k | x ) p ( c k ) Π n p ( t i | c k ) f c k ( t i ) .
Third, we used a support vector machine (SVM) model with a non-linear kernel function. It is a mathematical trick to allow SVM to separate non-linearly separable data in lower-dimensional space by adding more dimensions [37]. SVM creates a maximum-margin hyperplane by maximizing the distance between the separating line and the nearest points, called the support vectors [38].
y = w ϕ ( x ) + b ,
where ϕ is the kernel function. Finally, we used the random forest (RF) algorithm. It combines multiple decision tree algorithms and aggregate their results to produce better results. It can be considered one of the most efficient divide-and-conquer algorithms [39,40].
We utilized the above-mentioned algorithms to build the machine learning models to predict the geo-location of the tweets based on the extracted features. We then experimentally compared the predictability capabilities of these models in this noisy problem.

4.5. Pairwise Distance Matrix

Geo-location could mean detecting up to a block, a district, a city, or even a state. The distance between the actual location of the tweet and predicted location can be misleading. For instance, Abha is a city in the southern region neighboring another city of AlKhamis, with an approximately 5-mile distance. The accent and the lifestyle is exactly the same in both cities. However, Twitter geo-tagging distinguishes between them. Thus, there is no clear ground truth when evaluating the model. If we evaluated against the actual exact location, we would end up with very low performance even if the distance is 1 mile away. Therefore, we created a pairwise distance matrix D between cities from the class label for evaluation purposes. D R m × m is a square symmetric with a zero diagonal matrix, where m is the total number classes (illustrated in Figure A1).
The distance matrix was employed in the evaluation process by calculating the distance between the predicted and the actual targets. For example, if the model predicted the location of a tweet in city a, while it is in city b, the distance between a and b was retrieved from the distance matrix. Then, we set a distance threshold l for the prediction to be true if it is less than the threshold. In other words, this can be interpreted as creating a circle around each target with the threshold being the radius. Any tweet predicted to be in the circle can be assigned to the same class.
D = d 11 d 12 . . . d 1 m d 21 d 22 . . . d 2 m . . . . . . . . . . . . d m 1 d m 2 . . . d m m

5. Experiments and Results

5.1. Relevance of Geo-Tagging Features

The use of geo-tagging features for predicting the location of tweets is a challenging task that requires careful consideration of the features and models used. In our study, we explored the effectiveness of using both the home location found in users’ profiles and named entities (Table 6 shows some of the names extracted from the tweets) extracted from the tweets as features for location prediction.
Our results showed that the home location was a much more informative feature than the named entities, as its inclusion led to an increase in the prediction accuracy of around 25%. However, we also found that textual features, such as TF-IDF, played an important role in predicting the location, which suggests that a combination of textual and geo-tagging features may be the most effective approach.

5.2. Impact of Data Quality and Machine Learning Models

The accuracy of location prediction is dependent on the quality of the available data and the machine learning models used. To mitigate this, we performed data cleaning and preprocessing steps, such as removing irrelevant tweets and normalizing the text, to improve the quality of the dataset.
Our experiments (see Table 7) evaluated the impact of different machine learning models and features on location prediction accuracy. The random forest (RF) and support vector machine (SVM) models performed the best in terms of accuracy, with an average accuracy of over 67% when predicting locations within a range of 140 km. We also observed that the accuracy gains beyond 140 km were limited, which suggests that the social factor of language may play a role in location prediction accuracy as shown in Figure 2.
Incorporating elements of perplexity and burstiness, which are measures of text complexity and frequency, respectively, may further improve location prediction accuracy. However, these factors were not explicitly considered in our study, and future research could explore their impact on location prediction accuracy.

5.3. Comparison with Other Research Works

To understand how our results compare to those obtained by other researchers, we compared our results to those obtained using similar datasets and methods. Our results were comparable to those obtained in similar studies, which suggests that our approach to location prediction is a promising one.

5.4. Challenges in Improving Accuracy Further

Despite the promising results obtained in this study, there are several challenges that must be addressed to improve location prediction accuracy further. For example, accurately labeling the training data can be a challenge, especially when dealing with tweets in languages with complex syntax and grammar. Additionally, the limitations of the machine learning algorithms used in this study may have contributed to the limitations in accuracy gains beyond 140 km.
To address these challenges, future research could explore alternative approaches to feature extraction, such as incorporating sentiment analysis or social network analysis, or experimenting with different machine learning algorithms.
Our study provides insights into the relevance of geo-tagging features, the impact of data quality and machine learning models, and challenges in improving accuracy in location prediction. Our results suggest that a combination of textual and geo-tagging features and the use of RF and SVM models may be effective approaches to location prediction. However, further research is needed to address the challenges identified and to further improve location prediction accuracy.

6. Conclusions

In this study, we aimed to investigate location prediction using the content for Arabic tweets from Saudi Arabia using machine learning techniques with and without the utilization of a geo-distance matrix. Through extensive experimentation using a large number of tweets, we were able to achieve high accuracy rates in predicting the location of tweets. The use of a geo-distance matrix is a novel approach for location prediction using tweets. Furthermore, the proposed methodology used to achieve the objectives of this research yielded satisfactory results and can be utilized in real-world applications such as real-time event detection, intelligent transportation systems, location-based recommendations, and monitoring the public health of the citizens. The study also features an extraordinary feature that presents the predicted regions of tweets on the map of Saudi Arabia as shown in Figure 3, and an ability to predict the location of tweets based on textual data alone. However, the focus of the study was limited to Arabic tweets from Saudi Arabia, and, thus, the findings may not be generalizable to tweets in other languages or from other countries. Future research could examine the impact of other forms of data such as images and videos on location prediction, as well as explore the use of other forms of data and examine the results from other countries or languages to acquire a more comprehensive understanding of location prediction using tweets; using a transformer neural network can also be used to produce more accurate results.

Author Contributions

Conceptualization, M.A., S.A. and M.M.; methodology, M.A., S.A. and M.M.; software, M.M. and K.A.; validation, M.M., K.A. and A.A.; formal analysis, M.A. and S.A; investigation, M.M. and K.A.; resources, M.A. and S.A.; data curation, M.M. and K.A.; writing—original draft preparation, M.A., S.A. and M.M.; writing—review and editing, M.A., S.A., M.M., K.A. and A.A.; visualization, M.M. and K.A; supervision, S.A.; project administration, M.A., S.A., and M.M.; funding acquisition, M.A. All authors have read and agreed to the published version of the manuscript.

Funding

This research is financially supported by the Deanship of Scientific Research at King Khalid University under research grant number (RGP.2/157/43).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The dataset used in this study was collected by Center for Artificial Intelligence (CAI) at King Khalid University, and it is available from the corresponding authors upon request.

Acknowledgments

This work would not have been possible without the financial support offered by King Khalid University. We would like to express our deepest gratitude for their generous support.

Conflicts of Interest

The authors declare no conflict of interest.

Abbreviations

The following abbreviations are used in this manuscript:
GMMGaussian Mixture Mode.
VSMVector Space Mode.
TF-IDFTerm Frequency-Inverse Document Frequency.
CNNConvolutional Neural Network.
W-NUTWorkshop on Noisy User-generated Text.
LRLogistic Regression.
MNBMultinomial Naive Bayes.
SVMSupport Vector Machine.
RFRandom Forest.

Appendix A

Figure A1. Pairwise distance matrix.
Figure A1. Pairwise distance matrix.
Applsci 13 03025 g0a1

References

  1. Statista. Number of Active Twitter Users. Available online: https://www.statista.com (accessed on 22 December 2022).
  2. Abbasi, M.A.; Chai, S.K.; Liu, H.; Sagoo, K. Real-world behavior analysis through a social media lens. In Proceedings of the International Conference on Social Computing Behavioral-Cultural Modeling, and Prediction, College Park, MD, USA, 3–5 April 2012; Springer: Berlin/Heidelberg, Germany, 2012; pp. 18–26. [Google Scholar]
  3. Hasan, M.; Orgun, M.A.; Schwitter, R. Real-time event detection from the Twitter data stream using the TwitterNews+ Framework. Inf. Process. Manag. 2019, 56, 1146–1165. [Google Scholar] [CrossRef]
  4. Abdelhaq, H.; Sengstock, C.; Gertz, M. Eventweet: Online localized event detection from twitter. Proc. VLDB Endow. 2013, 6, 1326–1329. [Google Scholar] [CrossRef]
  5. Weng, J.; Lee, B.S. Event detection in twitter. In Proceedings of the Fifth International AAAI Conference on Weblogs and Social Media, Barcelona, Spain, 17–21 July 2011. [Google Scholar]
  6. Alhumoud, S. Twitter Analysis for Intelligent Transportation. Comput. J. 2019, 62, 1547–1556. [Google Scholar] [CrossRef]
  7. Hu, B.; Ester, M. Spatial topic modeling in online social media for location recommendation. In Proceedings of the 7th ACM Conference on Recommender Systems, Hong Kong, 12–16 October 2013; pp. 25–32. [Google Scholar]
  8. Rakesh, V.; Reddy, C.K.; Singh, D. Location-specific tweet detection and topic summarization in twitter. In Proceedings of the 2013 IEEE/ACM International Conference on Advances in Social Networks Analysis and Mining, Niagara, ON, Canada, 25–28 August 2013; pp. 1441–1444. [Google Scholar]
  9. Cheng, Z.; Caverlee, J.; Lee, K. You are where you tweet: A content-based approach to geo-locating twitter users. In Proceedings of the 19th ACM International Conference on Information and Knowledge Management, Niagara Falls, ON, Canada, 25–28 August 2013; pp. 759–768. [Google Scholar]
  10. Ao, J.; Zhang, P.; Cao, Y. Estimating the locations of emergency events from Twitter streams. Procedia Comput. Sci. 2014, 31, 731–739. [Google Scholar] [CrossRef] [Green Version]
  11. Sakaki, T.; Okazaki, M.; Matsuo, Y. Earthquake shakes Twitter users: Real-time event detection by social sensors. In Proceedings of the 19th International Conference on World Wide Web, Raleigh, NC, USA, 26–30 April 2010; pp. 851–860. [Google Scholar]
  12. Imran, M.; Castillo, C.; Diaz, F.; Vieweg, S. Processing social media messages in mass emergency: A survey. ACM Comput. Surv. 2015, 47, 67. [Google Scholar] [CrossRef]
  13. Graham, M.; Hale, S.A.; Gaffney, D. Where in the world are you? Geolocation and language identification in Twitter. Prof. Geogr. 2014, 66, 568–578. [Google Scholar] [CrossRef] [Green Version]
  14. Zheng, X.; Han, J.; Sun, A. A survey of location prediction on twitter. IEEE Trans. Knowl. Data Eng. 2018, 30, 1652–1671. [Google Scholar] [CrossRef] [Green Version]
  15. Sloan, L.; Morgan, J. Who tweets with their location? Understanding the relationship between demographic characteristics and the use of geoservices and geotagging on Twitter. PLoS ONE 2015, 10, e0142209. [Google Scholar] [CrossRef] [PubMed] [Green Version]
  16. Ritter, A.; Clark, S.; Etzioni, O. Named entity recognition in tweets: An experimental study. In Proceedings of the Conference on Empirical Methods in Natural Language Processing, Edinburgh, UK, 27–29 July 2011; pp. 1524–1534. [Google Scholar]
  17. Liu, X.; Wei, F.; Zhang, S.; Zhou, M. Named entity recognition for tweets. ACM Trans. Intell. Syst. Technol. 2013, 4, 3. [Google Scholar] [CrossRef]
  18. Liu, X.; Zhang, S.; Wei, F.; Zhou, M. Recognizing named entities in tweets. In Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies, Portland, OR, USA, 19–24 June 2011; Volume 1, pp. 359–367. [Google Scholar]
  19. Malmasi, S.; Dras, M. Location mention detection in tweets and microblogs. In Proceedings of the Conference of the Pacific Association for Computational Linguistics, Bali, Indonesia, 19–21 May 2015; Springer: Berlin/Heidelberg, Germany, 2015; pp. 123–134. [Google Scholar]
  20. Jurgens, D.; Finethy, T.; McCorriston, J.; Xu, Y.T.; Ruths, D. Geolocation prediction in twitter using social networks: A critical analysis and review of current practice. In Proceedings of the Ninth International AAAI Conference on Web and Social Media, Oxford, UK, 26–29 May 2015. [Google Scholar]
  21. Poulston, A.; Stevenson, M.; Bontcheva, K. Hyperlocal home location identification of twitter profiles. In Proceedings of the 28th ACM Conference on Hypertext and Social Media, Prague, Czech Republic, 4–7 July 2017; pp. 45–54. [Google Scholar]
  22. Mahmud, J.; Nichols, J.; Drews, C. Where is this tweet from? inferring home locations of twitter users. In Proceedings of the Sixth International AAAI Conference on Weblogs and Social Media, Dublin, Ireland, 4–8 June 2012. [Google Scholar]
  23. Ukkusuri, S.V.; Yang, C. Transportation Analytics in the Era of Big Data; Springer: Berlin/Heidelberg, Germany, 2019. [Google Scholar]
  24. Chang, H.w.; Lee, D.; Eltaher, M.; Lee, J. @ Phillies tweeting from Philly? Predicting Twitter user locations with spatial word usage. In Proceedings of the 2012 International Conference on Advances in Social Networks Analysis and Mining (ASONAM 2012), Istanbul, Turkey, 26–29 August 2012; pp. 111–118. [Google Scholar]
  25. Eisenstein, J.; O’Connor, B.; Smith, N.A.; Xing, E.P. A latent variable model for geographic lexical variation. In Proceedings of the 2010 Conference on Empirical Methods in Natural Language Processing, Cambridge, MA, USA, 9–11 October 2010; pp. 1277–1287. [Google Scholar]
  26. Mahmud, J.; Nichols, J.; Drews, C. Home location identification of twitter users. ACM Trans. Intell. Syst. Technol. 2014, 5, 47. [Google Scholar] [CrossRef] [Green Version]
  27. Flatow, D.; Naaman, M.; Xie, K.E.; Volkovich, Y.; Kanza, Y. On the accuracy of hyper-local geotagging of social media content. In Proceedings of the Eighth ACM International Conference on Web Search and Data Mining, Shanghai, China, 2–6 February 2015; pp. 127–136. [Google Scholar]
  28. Wing, B.P.; Baldridge, J. Simple supervised document geolocation with geodesic grids. In Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies, Portland, OR, USA, 19–24 June 2011; Volume 1, pp. 955–964. [Google Scholar]
  29. Roller, S.; Speriosu, M.; Rallapalli, S.; Wing, B.; Baldridge, J. Supervised text-based geolocation using language models on an adaptive grid. In Proceedings of the 2012 Joint Conference on Empirical Methods in Natural Language Processing and Computational Natural Language Learning, Jeju, Republic of Korea, 12–14 July 2012; pp. 1500–1510. [Google Scholar]
  30. Kinsella, S.; Murdock, V.; O’Hare, N. I’m eating a sandwich in Glasgow: Modeling locations with tweets. In Proceedings of the 3rd International Workshop on Search and Mining User-Generated Contents, Glasgow, UK, 28 October 2011; pp. 61–68. [Google Scholar]
  31. Paraskevopoulos, P.; Palpanas, T. Fine-grained geolocalisation of non-geotagged tweets. In Proceedings of the 2015 IEEE/ACM International Conference on Advances in Social Networks Analysis and Mining, Paris, France, 25–28 August 2015; pp. 105–112. [Google Scholar]
  32. Hulden, M.; Silfverberg, M.; Francom, J. Kernel density estimation for text-based geolocation. In Proceedings of the Twenty-Ninth AAAI Conference on Artificial Intelligence, Austin, TX, USA, 25–30 January 2015. [Google Scholar]
  33. Mostafa, A.; Gad, W.; Abdelkader, T.; Badr, N. Pre-HLSA: Predicting home location for Twitter users based on sentimental analysis. Ain Shams Eng. J. 2022, 13, 101501. [Google Scholar] [CrossRef]
  34. Mahajan, R.; Mansotra, V. Predicting geolocation of tweets: Using combination of CNN and BiLSTM. Data Sci. Eng. 2021, 6, 402–410. [Google Scholar] [CrossRef] [PubMed]
  35. Kleinbaum, D.G.; Dietz, K.; Gail, M.; Klein, M.; Klein, M. Logistic Regression; Springer: Berlin/Heidelberg, Germany, 2002. [Google Scholar]
  36. Kibriya, A.M.; Frank, E.; Pfahringer, B.; Holmes, G. Multinomial naive bayes for text categorization revisited. In Proceedings of the Australasian Joint Conference on Artificial Intelligence, Cairns, Australia, 4–6 December 2004; Springer: Berlin/Heidelberg, Germany; pp. 488–499. [Google Scholar]
  37. Noble, W.S. What is a support vector machine? Nat. Biotechnol. 2006, 24, 1565–1567. [Google Scholar] [CrossRef] [PubMed]
  38. Wang, L. Support Vector Machines: Theory and Applications; Springer Science & Business Media: New York, NY, USA, 2005; Volume 177. [Google Scholar]
  39. Biau, G.; Scornet, E. A random forest guided tour. Test 2016, 25, 197–227. [Google Scholar] [CrossRef] [Green Version]
  40. Breiman, L. Random forests. Mach. Learn. 2001, 45, 5–32. [Google Scholar] [CrossRef] [Green Version]
Figure 1. Prediction of location for Twitter users flowchart.
Figure 1. Prediction of location for Twitter users flowchart.
Applsci 13 03025 g001
Figure 2. Distance versus accuracy for location prediction using tweet text, home location, and named entity (RF model).
Figure 2. Distance versus accuracy for location prediction using tweet text, home location, and named entity (RF model).
Applsci 13 03025 g002
Figure 3. The predicted locations of the collected tweets.
Figure 3. The predicted locations of the collected tweets.
Applsci 13 03025 g003
Table 1. Example of the tweets.
Table 1. Example of the tweets.
IDLatitudeLongitudeUserHome
Location
Text
1**621.5**94539.13**93S**ilAbha,
Saudi Arabia
مركز الذكاء الاصطناعي
في جامعة الملك خالد
“The Artificial Intelligence
Center at King
Khalid University.”
https://t.co/p***1Mdt

Applsci 13 03025 i001
#Abha
Table 2. Data summary.
Table 2. Data summary.
ExplanationNumber of TweetsPercent
Total number of collected tweets from trending hashtags in Saudi Arabia50,000,000100%
Total number of tweets with geo-tags253,6730.5%
Total number of tweets with geo-tags in Saudi Arabia39,4180.08%
Total number of unique tweets with geo-tags in Saudi Arabia35,1100.07%
Total number of tweets after eliminating tweets that correspond to locations with less than five users or less than 70 tweets33,5450.067%
Total number of user profiles with home location1,946,3063.9%
Table 3. Assigned geo-tagged locations.
Table 3. Assigned geo-tagged locations.
CityLatitudeLongitudeClass Label
Abha18.216428242.50435961
Al Ahsa23.303607750.12588042
Al Bahah2041.53
Al Jubayl27.000696849.65321614
Al Kharj Industrial City23.916383247.281312915
Al Kharma21.91666742.56
Al Khobar26.303999950.19602377
Al Udayd22.5518
Al Kharj24.14833347.3059
Ar Ar130.981553141.016478810
Ar Rass25.868520543.503897811
At Taif21.27027840.41583312
Az Zahran26.296652850.120214613
Baljurshi19.85944441.55722214
Baqaa27.542.515
Bisha2042.616
Boriydah26.2765742543.3249806517
Buraydah 126.33166743.97166718
Dammam26.436782450.103999119
Jeddah21.5973494539.1336277920
Hafar Al Batin 227.90142945.528344221
Medina24.47115339.611121622
Ohd Rofida19.16666743.16666723
Rafha29.632418943.517868524
Riyadh24.631969246.715064825
Sabyaa17.33333342.66666726
Sakakah29.785109440.035443527
Sharoura1845.66666728
Tabuk27.537.33333329
Yanbu24.088901538.066679830
1 Boriydah; Class 17, and Buraydah; Class 18, can be slightly confusing. They refer to two distinct places but are not far from each other on the map. 2 This can be found as King Khalid Military City in Google Maps.
Table 4. Arabic diacritics.
Table 4. Arabic diacritics.
اَفتحهFath
اِكسرهKasr
اُضمهDamma
اّشدهShadda
Applsci 13 03025 i002سكونSukun
Table 5. Different Arabic formats.
Table 5. Different Arabic formats.
أ إ آاأكرم اكرم
ـةـهطباعة طباعه
يىعلي على
Table 6. Tweets and entity joints.
Table 6. Tweets and entity joints.
Tweet TextEnt1Ent2Ent3Ent4Ent5Ent6
موعدنا معكم غدا احد دوره تاثير مرض سكري على اعصاب مع استشاري طب اعصاب د احمد *** مستشفى سعودي *** حائل
‘Tomorrow is our appointment with Dr. Ahmed *** in Saudi *** Hospital Hail’
حائل
‘Hail’
-----
امطار رياض اعتقد ما فيه اجمل من انك تصحى على صوت مطر
‘Riyadh rains, I think it is nothing more beautiful than to wake up to the sound of rain’
رياض
‘Riyadh’
مطر
‘Rains’
----
اجواء ساحره في منطقه جنوبيه امطار خير وبركه ابها نماص تنومه باحه مندق بلجرشي اطاوله علايا بشاير
‘Charming weather in the southern region, good rain, a blessing Abha Namas Tanoma, you sleep in the courtyard of the hotel, Baha, the height of Alaya Bashyer’
أجواء
‘weather’
جنوبيه
‘Southern’
ابها
‘Abha’
نماص
‘Namas’
تنومه
‘Tanoma’
باحه
‘Baha’
الى اين مالذي يشغل بالك
‘Where are you on your mind’
------
Table 7. Accuracy of location prediction for each model using different features with respect to distance matrix.
Table 7. Accuracy of location prediction for each model using different features with respect to distance matrix.
Location Prediction Using
Tweet Text and
Home Location
Location Prediction Using
Tweet Text and
Named Entity
Location Prediction Using
Tweet Text,
Home Location,
and Named Entity
DistanceLRRFNBSVMLRRFNBSVMLRRFNBSVM
050.7964.5037.6654.5723.6541.7821.4227.7253.2664.5542.6455.96
2051.6465.1138.5555.3024.1741.9521.9328.1154.0765.1843.5356.71
4051.6765.1238.5955.3224.2341.9721.9928.1454.0965.1943.5756.73
6051.7465.1638.6855.3824.2541.9822.0628.1754.1665.2343.6556.79
8052.2765.5439.2255.8724.6142.1222.4428.4454.6665.6144.2057.23
10054.0266.6141.6957.1226.8243.6925.0230.2156.2266.6846.6458.42
12054.1066.6641.8857.1926.8943.7225.1530.2656.3066.7346.8058.50
14055.3267.2943.1358.5328.3144.5826.3731.7757.4267.3947.9959.76
16055.3967.3143.2258.5828.4444.6426.4931.8857.4867.4148.0959.81
18055.7467.5343.6058.8628.7344.8026.7832.1457.8267.6348.4260.07
20056.2667.7244.2859.3229.4945.0627.5232.8858.3367.8649.0460.52
22056.4667.7844.5159.4529.7745.1427.8233.0558.4967.9249.2660.64
24056.7167.8844.8159.6730.2145.2528.2333.3958.7468.0049.5560.85
26056.7467.8844.8959.6830.2445.2628.3233.4158.7768.0049.6360.86
28056.7767.8945.0059.7030.3345.2828.4533.4758.8068.0149.7360.87
30057.3568.1945.7360.1030.9945.5829.1533.9759.2968.3250.4061.26
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.

Share and Cite

MDPI and ACS Style

Alsaqer, M.; Alelyani, S.; Mohana, M.; Alreemy, K.; Alqahtani, A. Predicting Location of Tweets Using Machine Learning Approaches. Appl. Sci. 2023, 13, 3025. https://doi.org/10.3390/app13053025

AMA Style

Alsaqer M, Alelyani S, Mohana M, Alreemy K, Alqahtani A. Predicting Location of Tweets Using Machine Learning Approaches. Applied Sciences. 2023; 13(5):3025. https://doi.org/10.3390/app13053025

Chicago/Turabian Style

Alsaqer, Mohammed, Salem Alelyani, Mohamed Mohana, Khalid Alreemy, and Ali Alqahtani. 2023. "Predicting Location of Tweets Using Machine Learning Approaches" Applied Sciences 13, no. 5: 3025. https://doi.org/10.3390/app13053025

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop