# SDA-Vis: A Visualization System for Student Dropout Analysis Based on Counterfactual Exploration
## 3 Student Counterfactual Analysis
### Counterfactual Explanation  
A counterfactual explanation describes a causal situation in the \"_what-if_\" form. Broadly speaking, counterfactuals allow us to take action to cause a certain outcome. The action is an alteration in the features of the model to bring about the desired target response. Let us consider a learning model \(f(\theta,x)<\tau\), where \(f(\cdot)\) is the decision function, \(\theta\) is the parameter vector, \(x\) is the sample, and \(\tau\) is the decision threshold. A counterfactual consists of a synthetic sample \(x^{\prime}=x+a\) based on the action \(a\) that achieves the outcome \(y^{\prime}\); thus, \(f(\theta,x^{\prime})\geq\tau\). Since there are various ways to achieve the desired outcome, there can be multiple counterfactuals. These counterfactuals should balance the sparsity, diversity, and proximity. Sparsity is related to the number of features that need to be changed, diversity \begin{table}
\begin{tabular}{c l} \hline \hline
**Attribute** & **Variable** \\ \hline _ID_ & Student ID \\ \(N\_Cod\_Student\) & Number of enrollments at the university \\ _Gender_ & Gender of student (male/female) \\ _Age_ & Age of student (birth date) \\ _O\_IDH_ & Origin HDI \\ _O\_Poverty\_Per_ & Origin percentage of poverty \\ _R\_IDH_ & Residence HDI \\ _R\_Poverty\_Per_ & Residence percentage of poverty \\ _Marital\_S_ & Whether the student is married or not \\ _School\_Type_ & School type (private or public) \\ _N\_Reservation_ & Average number of reservations per semester \\ _Q\_Courses\_S_ & Number of lectures per semester. \\ _Q\_A\_Credits\_S_ & Number of passed credits \\ _Mandatory\_CPA_ & Average GPA of the mandatory lectures \\ _Electite\_GGA_ & Average GPA of elective lectures \\ _GPA_ & Final GPA score \\ _N\_Semesters_ & Number of completed semesters \\ _H\_Ausent\_S_ & Average absence rate per semester \\ _scholarship_ & Whether the student has a scholarship or not \\ _Enrolled_ & The student status (target) 1: Yes, 0: No \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Description of the data attributes collected from every student at the studied university. Figure 2: Correlation matrix for variables presented in Table 1.  
is the width of the range of the generated counterfactuals, and proximity relates to the similarity between the counterfactuals and the original instance. The basic form of counterfactual explanation was proposed by [PERSON] et al. (2012) as an optimization problem that minimized the distance between the counterfactual \(x^{\prime}\) and the original vector \(x\):  
\[ \begin{array}{c}\arg\underset{x^{\prime}}{min}\ dist(x,x^{\prime})\text{ subject to }f(x^{\prime})=y^{\prime}\end{array}  \tag{1}\]  
Converting to a differentiable, unconstrained form:  
\[ \begin{array}{c}\arg\underset{x^{\prime}}{min}\ \underset{\lambda}{max}\ \lambda(f(x^{\prime})-y^{\prime})^{2}+dist(x,x^{\prime})\end{array}  \tag{2}\]  
The first term encourages the model's output of the counterfactual to be close to the desired output. The second term forces the counterfactual to be relative to the original vector. Although diversity increases the chance that at least one example will be actionable, balancing this with the proximity (feasibility) is essential due to the large features. In this work, we are concerned about diversity and closeness, and therefore we rely on DiCE (Diverse Counterfactual Explanation) (Diverse, 2013), which is a variant of the form proposed by [PERSON] et al. (2012). DiCE balances the objective function incorporating terms that define _Proximity_ and _Diversity via Determinants Point Processes_ (or simply, DPP-Diversity). Proximity is calculated as \(-\sum_{i=1}^{k}\frac{\text{dist}(x^{\prime}_{i},x)}{k}\), where \(\text{dist}(u,v)\) is a distance function between the \(n\)-dimensional vectors \(u\) and \(v\). On the other hand DPP-Diversity is the determinant of the kernel matrix, given the counterfactuals (DPP-Diversity \(=\text{det}(K)\)).