# An Explainable Artificial Intelligence Approach for Detecting Empathy in Textual Communication
## 2 Preliminaries
### PBC4 cip  
The pattern-based classifier that we will use on this research is PBC4 cip: A contrast pattern-based classification algorithm built for class imbalance problems [27]. These classifiers are notorious since they are easy to understand by experts in the application domain [28]. A contrast pattern is a pattern that appears significantly more in a class when compared to the other classes [28], which grants them the advantages of effectiveness, comprehensibility, and ability to distinguish [28]. Previous research on contrast pattern-based classifiers [26; 27] has shown them to perform consistently better when compared to other classifiers like Naive Bayes, KNN, and support vector machines. Additionally, this approach has been previously used to solve real-life problems [27; 28], such as those found in the medical field. However, most pattern-based classifiers are not suitable for handling class imbalance issues. There are very few pattern-based classifiers that are built to take into account the class imbalance problem, among them are PBCEQ, PBC4 cip, and iCAEP [28]. These algorithms take the classifier level adjustment approach to solve the shortcomings presented by class imbalance, and they seem to perform well in various situations. PBC4 cip is based on the frequencies of patterns found by any mining algorithm [26]. Usually, when applied to class imbalance problems, contrast pattern miners extract several patterns with high support for the majority class and only a small number of patterns, with low support, for the minority class [26; 28]. This causes bias towards the majority class. The main idea behind PBC4 cip is that contrast patterns with low support for the minority class do not become overwhelmed by those patterns with high support for the majority class during the classification stage [26]. PBC4 cip proposes that the frequency sum of patterns that cover an instance be weighted according to the following expression:  
\[w_{c}=(1-\frac{|c|}{|T|})/\sum_{p\in P}\text{support}(p,c) \tag{1}\]  
In Equation (1), \(|c|\) represents the amount of instances that belong to class \(c\), \(T\) is the number of objects in the training dataset, \(P\) refers to the set of all patterns for the class \(c\), and \(\text{support}(p,c)\) represents the frequency of the pattern \(p\) in class \(c\)[26]. The term \((1-\frac{|c|}{|T|})\)will prioritize the class with a smaller number of representatives by punishing the sum of frequencies computed for the majority class. Additionally, the term \(\sum_{p\in P}\text{support}(p,c)\) is used for normalizing the sum of frequencies in each class regarding all patterns of the same class. This weight has as a purpose overcoming the bias of the classifiers towards a majority category. It assigns a higher weight for the minority class [26]. In the training phase, PBC4 cip obtains the patterns for each class and computes the weight \(w_{c}\). This is followed by the classification phase, in which the algorithm computes the sum of frequencies in each class for all the patterns matching with the instance \(w_{c}\)[26]. The sum is later multiplied by the weight:  
\[w_{Sum\_supp}(o,c)=w_{c}\sum_{ \begin{subarray}{c}p\in P\\ p\text{covers}\,o\end{subarray} }\text{support}(p,c) \tag{2}\]  
In Equation (2), \(w_{c}\) refers to the weight of the class \(c\), previously calculated in the training phase. \(\text{support}(p,c)\) is the frequency in class \(c\) of the pattern \(p\) covering to the instance \(o\). Equation (2) refers to the weight that a class has in a specific instance, different from \(w_{c}\). Therefore, we can use this value to select the class of the object of interest. For classification, PBC4 cip will select the class that presents the highest value for \(w_{Sum\_supp}(o,c)\) for each instance. We selected this algorithm as our focus on this research regarding pattern-based classification. This was decided thanks to these factors:  
1. The data we would use was imbalanced, a problem that PBC4 cip was designed to address [26]. 2.