## 3 Materials and Methods
### Shapley Values Implementation  
As discussed in the introduction, Shapley values are framed in cooperative game theory, and provide us with a way of assigning a payoff to each player: the average of all the marginal contributions of that player to each coalition of which he or she is a member. That is, those players who contribute more to the groups that include them should receive a higher payoff. Formally, one of the most common representations of a cooperative game is through the characteristic function. Let \(N=\{1,\dots,n\}\) be a finite, non-empty set of players, and \(S\subseteq N\) be a subset of players of \(N\) which we will call a coalition. A characteristic function set is given by the pair \((N,v)\), where \(v:2^{N}\rightarrow\mathbb{R}\) is a characteristic function that assigns to each coalition \(S\) a real number \(v(S)\). This number \(v(S)\) is often referred to as the \"value\" or contribution of the coalition \(S\)[5; 34]. Thus, the payoff assigned to player j is given by the corresponding Shapley value \(\phi_{j}(v)\) and is defined as follows [5]:  
\[\phi_{j}(v) = \phi_{j} = \sum_{S\subseteq N\setminus\{j\}}\frac{|S|!(n-|S|-1)!}{n!}[v(S \cup\{j\})-v(S)] \;\;\;,\;\;\forall j \in N \tag{1}\]That is, a weighted average is made, for all coalitions \(S\) that do not contain player \(j\), of the differences between the contribution when player \(j\) is included in the coalition and when is not included. Note that the empty set \(S=\emptyset\) is also part of the summation in the Equation (1). Therefore, the undistributed gain is also defined as follows \(\phi_{0}=v(\emptyset)\), which would be the fixed payoff that is not associated with any of the players. In order to apply this method to a machine learning model, it would, in general, be necessary to re-train the model for all feature subsets \(S\subseteq F\), where \(F\) is the set of all features [9; 35; 36; 37]. Therefore, to use the Equation (1) in this case, one would train a model \(f_{S\cup\{j\}}\) that includes feature \(j\) in its training set, and another model \(f_{S}\) that does not include that feature. With this in mind, making use of the notation of [9], we can adapt the Equation (1) as follows:  
\[\phi_{j}(f)\qquad=\qquad\phi_{j}\qquad=\qquad\sum_{S\subseteq F\setminus\{j \}}\frac{|S|!(|F|-|S|-1)!}{|F|!}\Big{[}f_{S\cup\{j\}}(x_{S\cup\{j\}})-f_{S}(x_{ S})\Big{]} \tag{2}\]  
where \(x_{S}\) and \(x_{S\cup\{j\}}\) represent, respectively, the values of the input features of the subsets \(S\) and \(S\cup\{j\}\) for instance \(x\). In this approach, the undistributed gain would be \(\phi_{0}=f_{\emptyset}(\emptyset)\), i.e., the model prediction that is not associated with any of the features. In our particular case, dealing with images as input data, applying this equation at the pixel level would be impractical, since we would have to form a total of \(2^{n}\) coalitions, where \(n\) is the number of pixels. However, if we divide the input images into standard sectors [38], as shown in Figure 2, and treat each sector as if it were a feature, the number of combinations is dramatically reduced, making the problem of computing Shapley values computationally tractable in a reasonable amount of time, even if we have to re-train the models for each possible coalition. This decision constitutes a key design trade-off in algorithm implementation: by treating sectors as features, we reduce the computational complexity of the Shapley value calculation from exponential in the number of pixels to exponential in the number of sectors (i.e., from \(2^{n}\) to \(2^{7}\)), making the algorithm feasible for execution while preserving anatomical relevance. This approach is similar to that adopted by [39], where a discretization of the problem is also proposed but through an arbitrary regular grid without medical significance. Figure 2: Diagram illustrating the division of the optic disc into six sectors: Nasal Superior (NS), Nasal (N), Nasal Inferior (NI), Temporal Inferior (TI), Temporal (T), and Temporal Superior (TS).