# Dealing with Gender Bias Issues in Data-Algorithmic Processes: A Social-Statistical Perspective
## 7 An Illustrative Numerical Example  
In order to illustrate some of the previously described concepts, this section introduces a numerical example that aims at: (i) showing a typical example of discrimination due to data bias, which lead us to a wrong model despite using logistic regression, which is a well-tested, gender-agnostic, and race-agnostic machine learning algorithm; and (ii) propose a simple yet effective methodology to solve the issue. Table 1 contains 92 observations related to bank users' applications for a financial credit during the last month. The following notation has been used: 'G' refers to gender, which can be _Male_ (M) or _Female_ (F); 'R' refers to race, which can be _White_ (W) or _Other_ (O); 'S' refers to the risk _Score_ (S) obtained by the applicant after a series of tests, where the higher the score, in a scale from 0 to 120, the more risk is assumed by the financial entity; finally, '\(A2\)' refers to whether the application has been approved by the bank (Y) or not (N). \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline \# & **G** & **R** & **S** & **A? ** & **\#**  
One could assume that the acceptance or rejection of the credit application should be mainly based on the score that the candidate has achieved after a series of rigorous tests -and, possibly, on some other variables-, but not on the actual gender or race of the candidate. Contingency tables can provide some insights on how the acceptance of the credits has been distributed by gender and race. Figures 4 and 5 show that while women represent around 30% of the sample, they only get around 26% of the accepted credits. This difference, however, does not seem to be statistically significant: for a standard \(\alpha\) value of 0.05, the Pearson Chi-Square test results in a \(p\)-value of 0.079 (and, a similar \(p\)-value is obtained with the Likelihood Ratio Chi-Square test). In the case of race, however, things are different: while non-white applicants represent around 51% of the sample, they only get around 41% of the approved credits. This results in both groups (white and other) being significantly different in terms of their odds to get a credit (both the Pearson and the Likelihood Chi-Square tests reflect an extremely low value of 0.001 for the associated \(p\)-value. \begin{table}
\begin{tabular}{c c c c c c c c c c} \hline  
Figure 7 shows the logistics regression model obtained. This model can be used to predict the probability that a new user's application is accepted, _P(Yes)_, based on the composed expression that employs exponential functions, \(exp(. )\), of a new variable \(Y^{\prime}\), which is defined as a piecewise function of the recorded variables. Hence, for instance, if the new candidate is a white female, \(Y^{\prime}=3.695-0.02945\cdot Score\), and so on. Figure 4: Contingency table of acceptation by gender. Figure 5: Contingency table of acceptation by race. Regression Equation  
P(Yes) = exp(T')/(1 + exp(T'))  
Gender Race  
Female Other Y' = 1.738 - 0.02945 Score  
Female White Y' = 3.695 - 0.02945 Score  
Male Other Y' = 3.100 - 0.02945 Score  
Male White Y' = 5.057 - 0.02945 Score  
Despite we found no significant gender differences when applying for a credit, the model is still proposing different coefficients for each gender. This is even worse in the case of race, where significant differences were found regarding the application rate of success. Figure 8 shows how the probability of having the application accepted varies with the risk score but also depends on the group to which a new customer belongs. Hence, for the same score a non-white female has significantly less options than a white male. Since the problem is not in the algorithm, it must be in the raw data. One easy way to correct this bias problem in the original data is to create a new model that does not consider either race or gender, but just score.