# Detection and Evaluation of Machine Learning Bias
## 4 Our Contribution
### Problem Statement  
In this paper, we aim to define, evaluate, and detect bias in machine learning models. Formally, we want to detect a subset of \(\mathbf{D}\); \(\mathbf{a}_{\mathit{Bias}}\subset\mathbf{D}\) that may introduce bias according to a specific evaluation metric. In this problem, and without loss of generality, we assume all potentially biased attributes to be categorized, and the class labels are discrete. Definition 1: Potentially Bused Attribute (PBA). Without loss of generality, we assume that \(\mathbf{a}_{j}\) is a categorical attribute. We can say that \(\mathbf{a}_{j}\in\mathbf{D}\) is a potentially biased attribute if \(f(\mathbf{D})\
ot\sim f(\varphi(\mathbf{D}))\). Where \(\varphi(\mathbf{D})\) is an alternation function; see Definition 3. We will denote the prediction of \(f(\varphi(\mathbf{D}))\) model as \(\mathbf{\hat{y}}_{\varphi}\). For the remainder of this paper, we call \(\mathbf{\hat{y}}_{\varphi}\) the alternative prediction. It is not the actual prediction. Instead, it is the prediction when we change the PBA's values using \(\varphi()\). For example, let \(\mathbf{D}\) be a dataset of \(n\) applicants, and \(\mathbf{a}_{j}\) is a gender attribute, while \(\mathbf{y}\) represents whether the applicant is qualified 1 or not qualified applicant 0. The problem in this scenario is to predict whether an applicant \(\mathbf{d}_{i}\) is qualified for a job or not. If \(\mathbf{a}_{j}\) is able to change the prediction by only changing the gender while maintaining the values of the remaining attributes, then the attribute \(\mathbf{a}_{j}\) is said to be a _potentially biased attribute_ (PBA). Bias Evaluation: KL Divergence  
Machine learning model is considered biased when the hypothesis prediction diverges with respect to one or more specific values of PBA. Formally, we can define machine learning bias as:  
**Definition 2**. : _A predictor is considered biased if it is dependent on one or more PBA given the class label [16; 19]._  
Assume the model, for instance, predicts the wage of a male instance with a specific amount. Then, we assume the same instance is passed to the model after changing the gender to a female. If the model's prediction changes dramatically by changing the gender only, this can be considered as model bias. We propose to evaluate bias amounts by quantifying the divergence between the densities of the predicted wages for the two predictors. We introduce a new concept to evaluate and quantify machine learning bias. We call this concept \"_alternation_\" function. **Definition 3**. : _Alternation is a function that alternates between attributes' values so the values are swapped each time._  
Alternation takes an attribute and changes the instance's identity. The purpose is to test the predictability consistency if the identity changes. If a female instance becomes male, is there any effect on the prediction? Similarly, if the race of an instance changes, does the prediction change accordingly? Alternation changes the identity of an instance. In another word, we aim to check the dependency of the predictor on the attribute. In this paper, we denote the alternation function as \(\varphi(\cdot)\). The function takes a dataset as an input and returns the alternative dataset, which is the dataset with alternative values of a specific attribute. \(\varphi(\mathbf{D})=\{\mathbf{a}_{1},\mathbf{a}_{2},\ldots,\
eg\mathbf{a}_{ j},\ldots,\mathbf{a}_{m}\}\). In this context, \(\varphi(\cdot)\) is a function that switches the protected attribute's values in a way that \(\mathbf{a}_{j}\) becomes \(\
eg\mathbf{a}_{j}\). Thus, the female values become male, and vice versa. We need to find the divergence between the distribution of the original class \(\mathbf{y}\) and the predicted classes \(\mathbf{\hat{y}}\) and \(\mathbf{\hat{y}}_{\varphi}\). Measuring the variation of information might indicate some differences between classes. However, bias should not be symmetric. The bias might be against or with certain attributes' values.