# Contextual Background Estimation for Explainable AI in Temperature Prediction
## 2 Materials and Methods
### Description of Mean Background Method  
One method we propose assumes the creation of a **mean background** that represents all the backgrounds capable of predicting the value \(y_{b}\) across the entire dataset. The entire dataset is a tensor \(\mathcal{D}\) consisting of matrices \(\mathbf{M}\). Each matrix (time-series sequence) can be used to obtain a result from the model (\(f(\mathbf{M})=y_{e}\)). The result \(y_{e}\) undergoes logical verification if it is within a small margin \(m\) away from \(y_{b}\). So, for each \(\mathbf{M}\) in \(\mathcal{D}\), we check if it meets the following condition:  
\[y_{b}-m\leq f(\mathbf{M})\leq y_{b}+m \tag{3}\]  
Each \(\mathbf{M}\) that meets this requirement is used to calculate the mean background. An important aspect of this approach, specific to meteorological time-series data, is that the target variable--in our case, temperature--exhibits its own frequency. Temperature generally increases from morning to late afternoon, decreases during the night, and repeats this cycle indefinitely. For hourly data, temperature follows a periodic pattern that repeats every 24 time steps. To represent this periodicity, we could calculate the mean values of each feature for each hour. Specifically, we would use all feature values recorded at 12 a.m. to create mean feature values for 12 a.m., those at 1 p.m. to create mean values for 1 p.m., and so on. This process enables us to construct an artificial background that mimics the real frequency of the data. This representation of frequency in the background may not be essential if the user is focused solely on explaining the importance of features rather than time steps. However, by incorporating this approach, we can prepare the backgrounds for further analysis of the importance of individual time steps. The Mean Background Method is summarized in the following steps and in Figure 5:1. checking which time-series sequences can be used to predict \(y_{b}\pm m\), where \(m\) is some small margin. In Figure 5, two example values are shown (\(y^{\prime}_{b}\) and \(y^{\prime\prime}_{b}\) );
2. all time-series sequences selected in step I can be used to create a mean time-series background that could resemble the frequency of the target;
3. an XAI method is applied to explain the changes between \(y_{b}\) and \(y_{e}\). In Figure 5, there are two values, \(y^{\prime}_{b}\) and \(y^{\prime\prime}_{b}\), which result in two different explanations for each feature. For example, moving the temperature prediction from \(y^{\prime}_{b}=-12\)\({}^{\circ}\)C to \(y_{e}=24\)\({}^{\circ}\)C might be influenced by different features than moving the prediction from \(y^{\prime\prime}_{b}=0\)\({}^{\circ}\)C to 24 \({}^{\circ}\)C.  
There is a drawback to the mean background obtained by the method described above. By averaging sequences, we risk creating a background that is significantly distinct from the values and trends present within the dataset. In other words, the resulting background may not accurately represent the true values provided in the dataset. For example, let us  
Figure 5: Schematic description of the Mean Background Method. assume the user wants to explain why the model predicted a temperature of 15 \({}^{\circ}\)C instead of 0 \({}^{\circ}\)C. Following the described steps, the user could identify all time-series sequences that lead the model to predict 0 \({}^{\circ}\)C. So, \(y_{e}=15\)\({}^{\circ}\)C and \(y_{b}=0\)\({}^{\circ}\)C. However, the user may not realize that, in this hypothetical example, there are two types of time-series sequences capable of predicting 0 \({}^{\circ}\)C. The first type consists of sequences with a downward trend in temperature approaching 0 \({}^{\circ}\)C, while the second type consists of sequences with an upward trend in temperature reaching 0 \({}^{\circ}\)C. Averaging these two types of sequences could produce a background that results in a prediction different from 0 \({}^{\circ}\)C. Moreover, consider a scenario where the user has two datasets but only one model.