# Contextual Background Estimation for Explainable AI in Temperature Prediction
## 1 Introduction
### The Aim of This Article  
Numerous widely used XAI methods rely on _base values_ or _backgrounds_ to generate explanations (as discussed in Sections 1.2.1 and 1.2.2). However, it is rarely addressed in the literature that base values and backgrounds **can significantly influence the explanations** provided by these methods, potentially causing **misleading results**. Furthermore, contextualized use of XAI is also barely discussed in the literature. Usually, approximated mean values of the entire dataset are used to calculate base values.  
The purpose of this article is to **develop and describe two new methods** aimed at improving the understanding of explanations and their reliability. The first method is called the **Mean Background Method** and the second is called the **Background Estimation Method**. These methods can help to assess the appropriateness and reliability of explanations, therefore providing a better understanding of the model's decisions. They can be applied particularly in sensitive domains such as power systems (Section 1.1). In this article, we present the results of tests conducted on models predicting temperature, a key indicator of electrical load (Section 3). The code used to obtain the results presented here is provided from the Gitlab repository ([[https://gitlab.com/[PERSON]/timeseries_explainer](https://gitlab.com/Barszo/timeseries_explainer)]([https://gitlab.com/[PERSON]/timeseries_explainer](https://gitlab.com/Barszo/timeseries_explainer)), accessed on 19 January 2025). Information regarding reproducibility with step-by-step instructions is described in the README file, which provides detailed information about the use of the methods presented here. They are open and free to use under the MIT license. In short, the results presented here were produced with the following libraries: modified timeSHAP 1.0.4 (the required modifications are described in the README), SHAP 0.45.1, tensorflow 2.15.0, and Python 3.11.10. Additionally, the authors provided three classes written in Python to facilitate the process: BackgroundHandler, ModelsForMeteorology, and TimeseriesData. They are all available from Gitlab.  
Specifically, the Mean Background Method can be used to prepare mean backgrounds for given base or reference values, as opposed to the default methods proposed by the authors of Kernel SHAP or timeSHAP. They assume calculating mean values and not leaving the possibility to specify a custom base value. The Mean Background Method is the first proposition of a more conscious background selection approach that meets the requirements of the user for contextualized problems. It does not modify either KernelSHAP or timeSHAP; instead, it is meant to obtain backgrounds that can be used with these XAI methods.  
The Background Estimation Method provides even more understanding of the influence of backgrounds that could be used for methods such as Kernel SHAP or timeSHAP. It can reveal the sources of fluctuations regarding explanations and provide more insight into the way the model makes decisions by providing context. With this method, the user can individually select which background (if any) of those existing in dataset time-series sequences will meet the demands.  
Both of these methods can also be used to demonstrate the limits of XAI methods in certain cases. If the XAI method is used to obtain importance and the proposed methods reveal large fluctuations caused by backgrounds, then it might mean that the given XAI method cannot be used to obtain the explanation and thus that the explanation cannot be trusted.