## 3 Methodology
### Extending to Local Explainability
#### 3.5.2 Two-Phase Approach for Local Explainability  
Our approach to local explainability consists of two phases: **Phase 1: Co Hoc: Integrating Local Explainability with Neighbors in Training.** In the first phase, we train the black-box predictor and white-box explainer models using our pre hoc or co hoc frameworks, incorporating the local neighborhood information. The loss functions are modified to include the local Jensen-Shannon divergence:  
For the Pre Hoc Local Explainability Framework:  
\[\mathcal{L}_{\text{Local-Pre hoc}}=\mathcal{L}_{\text{BCE}}+\lambda_{1}D_{JS _{local}}+\lambda_{2}\mathcal{L}_{2} \tag{18}\]  
For the Co Hoc Local Explainability Framework:  
\[\mathcal{L}_{\text{Local-Co hoc}}=\mathcal{L}_{\text{f-BCE}}+\mathcal{L}_{g \text{-BCE}}+\lambda_{1}D_{JS_{local}}+\lambda_{2}\mathcal{L}_{2}(f)+\lambda_ {2}\mathcal{L}_{2}(g) \tag{19}\]  
**Phase 2: Computing Local Explanations,** Algorithm 1. In the second phase, for each test instance \(x_{i}\), we identify its nearest neighbors from the training set, forming a local in-testing neighborhood \(\mathcal{N}(x_{i})\). We then fine-tune the global white-box explainer model within this neighborhood to obtain a local explainer model \(g_{\phi_{i}}^{local}\). The fine-tuning is performed by minimizing the following:  
\[\mathcal{L}_{\text{Local-Explainer}}=D_{\text{JS}_{\text{local}}}^{expl}(g_{ \phi_{i}}^{local},\hat{y}_{\theta}) \tag{20}\]  
We use a nearest neighborhood algorithm to identify a set of neighboring instances for each local instance in the dataset, such as k-nearest neighbors (k-NN) with Euclidean distance. The intuition behind considering local neighborhoods is that similar inputs are expected to have similar outputs while capturing the model's behavior near each instance by focusing on the local neighborhood.  
This fine-tuned local explainer model provides instance-specific explanations that capture the local behavior of the black-box model around the test instance. The feature importance scores are then extracted from the local explainer model, quantifying the contribution of each feature to the model's prediction for that specific instance.  
```
0: White-box model \(g_{\phi}^{global}\), input training instances \(X_{train}\) with their true labels \(y\), nearest neighborhood function \(GetNeighbors()\), number of neighborhood instances \(k\), testing instance \(x_{i}\) \(\mathcal{N}^{testing}(x_{i})\leftarrow\text{GetNeighbors}(x_{i},k,X_{train})\)\(\triangleright\) Get k-NN to training instance \(x_{i}\) from training set  Compute \(p_{\phi}=g_{\phi}^{global}(\mathcal{N}^{testing}(x_{i}))\)\(\triangleright\) Predictions from explainer model for All \(x_{j}\in\mathcal{N}^{testing}(x_{i})\)do\(\triangleright\) Get predictor outputs for the local training neighbors \(g_{\phi,i}^{local}\gets g_{\phi}^{global}(x_{j})\) endfor\(\triangleright\) initialize local model to the global model for t=1 to \(T_{finetune}\)do for All \(x_{j}\in\mathcal{N}^{testing}(x_{i})\)do\(\hat{g}_{\phi,i}^{local}\gets g_{\phi}^{local}(x_{j})\)\(\triangleright\) Get local explainer outputs for the local training neighbors endfor Update Local Explainer Loss \(\mathcal{L}_{\text{Local-Explainer}}\) using Equation (20) \(\phi_{i}\leftarrow\phi_{i}-\alpha\
abla_{\phi_{i}}\mathcal{L}_{\text{Local- Explainer}}\)\(\triangleright\) Update \(g_{\phi_{i}}^{local}\) using gradient descent endfor Extract feature importances feature_importances from \(g_{\phi_{i}}^{local}\) using Equation (21) and the set of features in the data return feature_importances
```  
**Algorithm 1** Testing PHASE 2: Computing Local Explanations