# An Explainable Artificial Intelligence Model for Detecting Xenophobic Tweets
## 2 Preliminaries
### Contrast Pattern-Based Classification
For example, Figure 1 shows an example of a hypothetic decision tree for Xenophobia classification. From this decision tree, we can extract the following six contrast patterns:  
* \(\mathrm{P_{1}}=[\textit{Hate-speech}\leq 0.20]\land[\textit{Positive}<0.53]\land[ \textit{Foreigners}\
eq\textit{\"Present\"}]\)
* \(\mathrm{P_{2}}=[\textit{Hate-speech}\leq 0.20]\land[\textit{Positive}<0.53]\land[ \textit{Foreigners}=\textit{\"Present\"}]\)
* \(\mathrm{P_{3}}=[\textit{Hate-speech}\leq 0.20]\land[\textit{Positive}\geq 0.53]\)
* \(\mathrm{P_{4}}=[\textit{Hate-speech}>0.20]\land[\textit{Violent Foreigners}=\textit{\"Present\"}]\)
* \(\mathrm{P_{5}}=[\textit{Hate-speech}>0.20]\land[\textit{Violent Foreigners}\
eq \textit{\"Present\"}]\land[\textit{Angry}\leq 0.20]\)
* \(\mathrm{P_{6}}=[\textit{Hate-speech}>0.20]\land[\textit{Violent Foreigners}\
eq \textit{\"Present\"}]\land[\textit{Angry}>0.20]\)  
from which \(\mathrm{P_{1}}\), \(\mathrm{P_{3}}\), \(\mathrm{P_{5}}\) corresponds to the _Non-Xenophobia_ class and the remaining patterns (\(\mathrm{P_{2}}\), \(\mathrm{P_{4}}\), \(\mathrm{P_{6}}\)) corresponds to the _Xenophobia_ class. For filtering the contrast patterns, there exist two main approaches, based on set theory (i) and quality measures (ii) [33]. The first approach removes duplicate and specific patterns and also removes redundant items. The second approach allows generating a pattern ranking in which the raking position is based on the discriminative power of the patterns. It can be explained the three main steps of the contrast pattern filtering process based on the set theory as follows:  
* **Removing duplicated contrast patterns:** when two or more contrast patterns have the same items and cover the same objects, they are called duplicate patterns. This problem usually happens because the contrast patterns come from several decision trees built from the same training database. Then, all the duplicated contrast patterns are removed to reduce the contrast patterns, and only one is kept. * **Removing specific contrast patterns:** commonly, some specific patterns are extracted in the mining process. Let us suppose that there are two contrast patterns \(\mathrm{P_{1}}\) and \(\mathrm{P_{2}}\), that belong to the same class. The pattern \(\mathrm{P_{2}}\) is considered more specific than  
Figure 1: Decision Tree example. \(\text{P}_{1}\) if all the items contained in \(\text{P}_{1}\) are also in \(\text{P}_{2}\) but not vice versa. For example, let \(\text{P}_{1}\) = [_Hate-speech_\(\leq 0.20\)] \(\wedge\) [_Positive_\(\geq 0.53\)] and \(\text{P}_{2}\) = [_Hate-speech_\(\leq 0.20\)] \(\wedge\) [_Positive_\(\geq 0.53\)]\(\wedge\) [_Negative_\(<0.24\)]. Since all the items presented in \(\text{P}_{1}\) are also in \(\text{P}_{2}\), but \(\text{P}_{2}\) has one more item, then \(\text{P}_{2}\) is considered more specific than \(\text{P}_{1}\). Therefore, according to [48], \(\text{P}_{2}\) should be removed. * **Removing redundant items:** An item \(\text{I}_{1}\) is more general than another item \(\text{I}_{2}\) if all of the objects presented in \(\text{I}_{1}\) are also in \(\text{{}_{2}}\), but not the other way around. We also say that \(\text{I}_{2}\) is redundant with \(\text{I}_{1}\). If two items in a pattern are redundant, the most general item is eliminated [3]. We can provide the next example of a pattern with redundant items: [_Hate-speech_\(>0.20\)] \(\wedge\) [_Hate-speech_\(>0.41\)], which is simplified to [_Hate-speech_\(>0.41\)] because an entry with a hate-speech greater than \(0.41\) is also greater than \(0.20\). To explain the second approach of filtering the contrast pattern based on quality measures, let us take the support as our quality measure.