# Predicting Location of Tweets Using Machine Learning Approaches
## 3 Data Collection and Preparation
### 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 \(\textbf{c}=\{1,2,...,30\}\), where the classes were assigned as shown in Table 3.  
\begin{table}
\begin{tabular}{l c c c c} \hline \hline
**ID** & **Latitude** & **Longitude** & **User** & **Home** & **Text** \\ \hline \hline
1**\({}^{\ast}\)6 & 21.5**\({}^{\ast}\)945 & 39.13**\({}^{\ast}\)93 & S**\({}^{\ast}\)il & Abha, Saudi Arabia & “The Artificial Intelligence Center at King Khalid University.” \\  & & & & \\  & & & & \\  & & & & \\  & & & & \\  & & & & \\ \end{tabular}
\end{table}
Table 1: Example of the tweets.  
\begin{table}
\begin{tabular}{l c c} \hline \hline
**Explanation** & **Number of Tweets** & **Percent** \\ \hline Total number of collected tweets from trending hashtags in Saudi Arabia & 50,000,000 & 100\% \\ \hline Total number of tweets with geo-tags & 253,673 & 0.5\% \\ \hline Total number of tweets with geo-tags in Saudi Arabia & 39,418 & 0.08\% \\ \hline Total number of unique tweets with geo-tags in Saudi Arabia & 35,110 & 0.07\% \\ \hline Total number of tweets after eliminating tweets that correspond to locations with less than five users or less than 70 tweets & 33,545 & 0.067\% \\ \hline Total number of user profiles with home location & 1,946,306 & 3.9\% \\ \hline \hline \end{tabular}
\end{table}
Table 2: Data summary.  
\begin{table}
\begin{tabular}{l c c} \hline \hline
**City** & **Latitude** & **Longitude** & **Class Label** \\ \hline Abha & 18.2164282 & 42.5043596 & 1 \\ \hline Al Ahsa & 23.3036077 & 50.1258804 & 2 \\ \hline Al Bahah & 20 & 41.5 & 3 \\ \hline Al Jubayl & 27.0006968 & 49.6532161 & 4 \\ \hline Al Kharj Industrial City & 23.9163832 & 47.28131291 & 5 \\ \hline Al Kharma & 21.916667 & 42.5 & 6 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Assigned geo-tagged locations.