# Mitigating Digital Ageism in Skin Lesion Detection with Adversarial Learning
## 3 Methods  
### Fair Skin Lesion Detection  
Consider a medical image with metadata consisting of tuples \((x_{i},a_{i},y_{i})\) in \(\mathcal{R}^{n}\), \(i\in 1,...,N\), where \(x_{i}\) is the input skin lesion image, \(a_{i}\) denotes the metadata, \(y_{i}\) is the class label \(\{benign,malignant\}\) from the set X, Y, and A, and a pretrained encoder \(f_{E}:\mathcal{R}^{n}\rightarrow\mathcal{R}^{m}\) yields the representations \(Z\). Each \(x_{i}\) is a high-resolution image represented as a 3-dimensional matrix of dimensions \(W\times H\times C\), where W, H, and C are the width, height, and the number of color channels (typically C = 3 for RGB images). The metadata \(a_{i}\) consist of vectors of real-valued attributes associated with each image. They are represented as \(a_{i}\in R^{M}\), where M is the number of metadata attributes, such as age, gender, weight, and height. The class label \(y_{i}\) is a binary indicator representing the diagnosis of a skin lesion in the image \(x_{i}\). It takes values from the set A 0,1, where 0 corresponds to 'benign' and 1 to'malignant'. The classifier learns to predict \(y_{i}\) based on the representation \(Z\) from the input image. In the context of mitigating age-related bias in skin lesion detection, the encoder \(f_{E}\), decoder \(f_{D}\), and classifier \(g(Z)\) work together to minimize both the classification loss and the reconstruction error, while also minimizing the objective of the adversary \(h(Z)\). In the adversarial framework, we establish a competitive yet collaborative environment between the classifier and the adversary. The classifier aims to maximize its predictive accuracy to detect skin lesions, while the adversary strives to minimize the classifier's ability to discern sensitive attributes, such as age, from the latent representation. This dynamic creates a minimax game, where the objective is to find a balance where the classifier performs well on the primary task without relying on sensitive attributes that the adversary is trying to 'protect' from being predictive. However, there are several operational challenges when working with adversarial networks that should be proactively considered, including vanishing gradients, mode collapse, and convergence problems [28]. Furthermore, data poisoning and other malicious data injections can severely undermine the predictive abilities of adversarial networks [29]. Unlike [PERSON] et al. [14], in our problem, input \(x_{i}\) is not a tabular dataset [30] but skin lesion images with metadata. Moreover, our sensitive attribute is age, which is a continuous variable rather than a discrete variable (e.g., ethnicity, sex, or gender). We aim to maximize the prediction performance while minimizing the bias against sensitive attributes:  
\[\min_{f_{E},g,f_{D}}\max_{h}\mathbb{E}_{X,Y,A}[L(f_{E},g,h,f_{D})], \tag{1}\]  
In this equation, \(f_{E}\) represents the encoder that extracts features from the input images \(x_{i}\), \(g\) is the classifier that predicts the class labels \(y_{i}\), and \(f_{D}\) is an optional decoder that may reconstruct the images from the latent features. The adversary \(h\) attempts to predict the sensitive attribute \(a_{i}\) (such as age) from the features to ensure fairness. The expectation \(\mathbb{E}_{X,Y,A}\) is taken over the input images \(X\), labels \(Y\), and sensitive attributes \(A\), while \(L(f_{E},g,h,f_{D})\) is the loss function that balances both prediction accuracy and fairness. Our objective function is expressed as  
\[ \begin{split} L(f_{E},g,h,f_{D})=&\alpha L_{C}(g(f_ {E}(X,\hat{A})),Y)\\ +&\beta L_{Dec}(f_{D}(f_{E}(X,\hat{A}),\hat{A}),X) \\ &+\gamma L_{Adv}(h(f_{E}(X,\hat{A})),\hat{A})\end{split}  \tag{2}\]The classification loss \(L_{C}\) ensures accurate classification; the \(L_{Dec}\) reconstruction loss enhances the accuracy of data reconstruction by the deep variational autoencoder (VAE), promoting meaningful representation learning and improving the data quality. The adversarial loss \(L_{Adv}\) promotes fairness.