# A Comparative Study of Two Rule-Based Explanation Methods for Diabetic Retinopathy Risk Assessment
## 3 Preliminaries
### Contextualised LORE for Fuzzy Attributes (C-LORE-F)  
C-LORE-F is a variant of the LORE and Guided-LORE methods for fuzzy-based ML models. It provides an explanation for the decision assigned to a specific instance based on some contextual information (e.g., the type of attribute and the fuzzy sets associated to the linguistic values of the fuzzy attributes). The inputs of C-LORE-F are a trained fuzzy-based ML model, \(b\), and an example \(x\). Algorithm 1 shows the main steps of C-LORE-F. First, we apply \(b\) to \(x\) to get a decision \(y\). We obtain a set of neighbours of \(x\), \(D\), and a rule-based model \(t\) is built by considering the output of \(b\) in these points. From this model \(t\) it is possible to derive an explanation, that contains the rule \(r\) used to classify \(x\), a set of counterfactual rules \(\delta\) and a set of counterfactual instances \(\mathbb{C}\). ```
input :\(x\): an instance to explain, \(T\): an auxiliary set, \(b\): a black-box model, \(L\): maximum level of exploration, and \(KB\): knowledge base. output :\(E\): the explanation of the decision of \(b\) on \(x\)
1\(y\gets b(x)\) ;
2\(\mathcal{D}^{+}\leftarrow\mathit{GetNeighours}(x,y,b,L,KB)\) ;
3\(x^{-},y^{-}\leftarrow\mathit{FindDiff}\mathit{Example}(x,y,b,T)\) ;
4\(\mathcal{D}^{-}\leftarrow\mathit{GetNeighours}(x^{-},y^{-},b,L,KB)\) ;
5\(\mathcal{D}\leftarrow\mathcal{D}^{+}\cup\mathcal{D}^{-}\) ;
6\(t\leftarrow\mathit{BuildModel}(\mathcal{D},b)\) ;
7\(r=(p\to y)\leftarrow\mathit{ExtractRule}(x,t)\) ;
8\(\delta\leftarrow\mathit{ExtractCounterfactualRules}(x,r,t)\) ;
9\(\mathbb{C}\leftarrow\mathit{ExtractCounterfactuals}(x,\delta,t)\) ;
10\(E\leftarrow(r,\delta,\mathbb{C})\) ;
```  
**Algorithm 1**C-LORE-F  
The set \(\mathcal{D}\) is obtained by merging two subsets, \(\mathcal{D}^{+}\) and \(\mathcal{D}^{-}\). The first one is called the positive set, and it contains a set of instances that belong to the same class of \(x\). The second one, the negative set, contains examples with a different class. We obtain \(\mathcal{D}^{-}\) by looking at an auxiliary set \(T\) and finding the closest example to \(x\), i.e., \(x^{-}\), that has a different label than \(y\). \(T\) can be the training set used to train the black-box model, if accessible, or any other data set from the same distribution. The neighbours generation step is the key point in C-LORE-F and similar methods. As a first change with respect to LORE and Guided-LORE, we have defined the following types of attributes. * Attributes with a fixed value (e.g., sex). * Attributes whose value increases in time (e.g., age). * Attributes whose value decreases in time (e.g., years left until retirement). * Variable attributes, that can change positively and negatively (e.g., weight). The motivation of such definitions is to generate useful and actionable explanations. For example, nobody can reduce his/her age, so it is not useful to give a counterfactual rule saying \"if you were 10 years younger, your risk of developing DR would be much lower\". We define the neighbourhood generation as a search problem in which we explore the neighbourhood space of a point \(x\) by applying a Uniform Cost Search based on the Heterogeneous Value Difference Metric (HVDM, [26]), using some contextual information about the attributes (e.g., the attribute type and the fuzzy set definitions). This search problem can be formulated as follows:  
* **State Space**: the set of all possible examples \(S\). * **Initial State**: \((x,y)\), where \(x\) is the instance of which we want to generate its neighbours and \(y\) is the label of this instance obtained by the black-box \(b\). * **Actions**: Modifications of the value of a single attribute (feature). These actions leverage some contextual information about the feature to make the desired changes to generate new neighbours. In our case, we define two types of actions, next and prev, described later. * **Transition Model**: returns a new instance in which the value of a feature is changed by applying all actions.