# A Framework to Understand Attitudes towards Immigration through Twitter
## 4 Methodology
### Attitude Classification and Propagation  
To predict attitudes, we follow a bootstrapped approach, where we propagate the user labels from the previous step to the rest of the dataset. We use the XGBoost classifier that trains decision trees using gradient boosting [71]. The input feature matrix is the concatenation of several matrices:  
* A content-term matrix, where each row represents user \(i\), and each term \(j\) can represent a word, hashtag, username, URL or emoji. Thus, a cell \((i,j)\) contains the number of times user \(i\) has used the term \(j\) in their tweets. * A profile-term matrix, analogous to the previous one, but this time for the terms contained in the full name and biographical self-description of each user. * A profile-domain matrix, mapping to each user's home page its main domain (e.g., twitter.com) and their main top level domain (e.g.,.com). * Since homophily may vary or be absent in different interaction layers [72], we consider the three types of interaction separately. Thus, we build three adjacency matrices based on the interactions in the discussion: retweets, replies, and quotes. Each matrix stores in a cell \((i,j)\), the number of times user \(i\) has interacted with user \(j\) (for instance, if \(i\) retweets \(j\) one time, \(c(i,j)=1\)). \begin{table}
\begin{tabular}{c l} \hline \hline
**Attitude** & **Seed Words and Hashtags (and Their Frequencies in Dataset)** \\ \hline \multirow{5}{*}{Empathy} & \#bienveniodsachite (_teelome to Chile_, 26), achilesibarraeras (_Chile without barriers_, 7), \\  & \#chilediverso (_Diverse Chile_, 43), \\  & _more canophobia_, 30), \#arcsimo (_naxim_, 1336), \\  & _more racsimo_, 10), \#noalracismo (_no racsim_, 7), \\  & _more racsim_, 10), \#noalracismo (_no racsim_, 7), \\  & _immigrants_, 67), \\  & _all migrants_, 1108), \#bienveniodsimartens (_welcome migrants_, 6), \\  & _human being is illegal_, 16), \#nadiesilegal (_no arc is illegal_, 29), \\  & _being is illegal_, 22), \#redmigrant (_nigrant network_, 105), \#interculturalidad (_interculturality_, 218), \\  & \#dialedmigrante (_migrant’s day_, 269), \#sinfronteras (_without borders_, 371), \\  & 349), multicultural (372), diversidad (_diversity_, 1531) \\ \hline \multirow{5}{*}{Threat} & \#immigrantselesides (_libreal immigrants_, 7), \#nonanimismismaries (_no more immigrants_, 41), \\  & \#vendeparta (_cells homeland_, 5), \#estadodecastro (_state of catastrophe_, 44), invasion (_invasion_, 1258), invaden (_they invade_, 62), \\  & \#vendeparta (_type group generating chaos_, 732), prestamistas \\  & (_monojdanders_, 372), narcotrafac (_drug trafficking_, 531), \\ \cline{1-1}  & _border_, 292), enfermedades (_disasses_, 2138), narcotrafacants (_drug dalers_, 291), expulsarlos (_eject them_, 105), eachx (_to take them out_, 1172), deportarlos (_daport than_, 88) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Seed patterns for each attitude toward immigration. A user-attitude interaction matrix for each type of interaction, where each cell contains the number of times the corresponding user has interacted with other users that were labelled with an attitude. Then, we train the classifier using the set of labelled users. To avoid overfitting, we take two measures. First, the gradient boosting is performed with early stopping, using a validation set of 15% of the training observations. Second, we removed columns from the feature matrix that were used for labelling. This includes the seed keywords for each attitude, as they perfectly separate users from both groups and our goal is to classify users who do not use these terms in their content. After having trained the classifier, we predict the attitude of the rest of the dataset. For a given profile \(u\), the classifier outputs a value \(p_{a}(u)\) for each attitude \(a\) that lies in \([0,1]\), corresponding to the fraction of decision trees that vote for the corresponding attitude. Note that the value of \(p_{a}(u)\) is not a real probability.