# Artificial Intelligence Algorithms for Treatment of Diabetes
## 2 Methods
### ML with Electronic Health Records for Personalized Medicine and Decision Making in T2D  
EHR data can be generally divided into two categories: structured data and unstructured data. Structured EHR data includes demographic information, laboratory results, prescribed medication, diagnosis codes, etc. Unstructured EHR data contains the clinical notes and free text notes written by doctors and medical practitioners. ML models on both types of data have been shown biased against certain demographic groups [67]. For example, the predictions of multiple neural models on the MIMIC-IV dataset have been found to have race-level discrepancies [68]. There exists a performance disparity between demographic groups for a gradient boosting model on the Translational Research Integrated Database Environment (STRIDE 8) dataset [69]. The use of pooled cohort equations (PCE) method is also verified as biased to help guide physicians [3; 70]. In addition to the structured data, bias issues also exist in unstructured data for tasks such as automated question answering (QA) tasks [71] and text generation [72]. The goal of general equitable/fair ML is to build an effective algorithm for prediction while still satisfying fairness constraints. Following existing fair ML work [73; 74], the performance of fairness can be measured with metrics such as equal opportunity and statistical parity. Equal opportunity requires that the probability of positive instances with arbitrary protected attributes being assigned to a positive outcome are equal; statistical parity requires the behavior of the prediction model to be fair to different sensitive groups. Bias in algorithms can come from different sources such as unrepresentative or incomplete training data or the reliance on flawed information that reflects historical inequalities [75]. Bias can also come from the algorithm design without considering fairness criteria or come from user interactions such as user behavior bias. To ensure fairness in ML algorithms, recent advancements in fairness-aware models aim to optimize different fairness measures including individual fairness and group fairness: individual fairness aims to give similar predictions to similar individuals with counterfactual fairness or fairness through awareness; while group fairness is to treat different groups equally measures like statistical parity and equalized odds. An algorithm that is unbiased to the sensitive attributes, \(s\in\{0,1\}\), can be obtained by incorporating constraints in the optimization problem that impose fairness on the model. The goal of finding a mapping that provides both accurate predictions and fairness guarantees can be achieved by incorporating constraints that ensure the parameter estimates result in classification results that are independent of the sensitive attributes. The model parameters of a fair model can be obtained by solving the following constrained optimization problem:  
\[\theta^{*}=\underset{\theta\in\Theta}{\text{argmin}}\mathcal{L}(\theta, \mathcal{D}) \tag{1}\]  
\[\text{s.t.}\quad C(\theta,\mathcal{D})\leq\delta \tag{2}\]  
with  
\[C(\theta,\mathcal{D}):=\underset{y\in\{0,1\}}{\max}[P(\hat{y}\
eq y|s=0)-P( \hat{y}\
eq y|s=1)]\leq\delta \tag{3}\]where a relaxed probabilistic constraint computed over the training data \(\mathcal{D}\) is introduced so that the estimated model parameters yield approximately equalized odds, biases, and accuracies with respect to the protected attribute \(s\) and outcome \(y\). The constraint, \(C(\theta,\mathcal{D})\), expressed generally as \(P(\hat{y}|x,s)=P(\hat{y}|x)\), or the independence of the predicted outputs with respect to the sensitive attributes, enforces conditional independence between model predictions \(\hat{y}=f_{\theta}(\mathcal{X})\) and the sensitive attribute \(s\) as conditional prediction parity [76; 77], ensuring the overall misclassification rate is not affected by the sensitive attributes.