# Approaches for Dealing with Seasonality in Clinical Prediction Models for Infections
## 3 Materials and Methods
### Proposed Adaptations to Dail with Seasonality
#### 3.4.1 Sliding Windows  
One of the earliest techniques proposed to address concept drift was the use of sliding windows [21]. The underlying hypothesis of this approach is that the newest datapoints are more useful than the older ones when attempting to predict the target outcome to the point that the oldest ones can be discarded when training a prediction model. Therefore, only those data points within a determined time interval (i.e., the time window) are used to build the prediction model. This framework has been the starting point for many other methods, and is commonly used as a baseline in the evaluation of new algorithms [36].  
However, the traditional sliding window approach and its subsequent improvements require an ordered datastream. If it is not possible to estimate the real timestamp of the data, or if they are not ordered by occurrence, then these approaches cannot be applied.  
We propose an adaptation of the sliding window approach focused on dealing with the problem of seasonality in those cases in which only the month or the season of the data are known. The proposed method is formally described in the functions _WindowTraining_ (Algorithm 1) and _WindowPredict_ (Algorithm 2). Let us assume that it is necessary to make a prediction for a datapoint \(d_{m}\) belonging month \(m\) and that in our training dataset we know the month in which each observation was made. We first partition our training dataset by the month of its observations, after which we create a window of a predefined size \(w\) around the data obtained in \(m\). This window contains data from \(w\) months; therefore, it includes the training data for month \(m\), the previous \(\frac{w-1}{2}\) months, and the subsequent \(\frac{w-1}{2}\) months, where \(w\) is assumed to be an odd number.  
```
0:\(w\): Size of the window with \(w\in\{1,3,5,7,9,11\}\) in the monthly version, or \(w=3\) in the seasonal version
0:\(\mathcal{D}\): Training dataset
0:\(\mathcal{K}\): A set with a model for each month/season
1: Aggregate data in \(\mathcal{D}\) by month/season
2:for each month/season \(m\)do
3:\(D_{m}\leftarrow\) data of \(w\) months/seasons from \(\mathcal{D}\), gathering data from month/season \(m-\frac{w-1}{2}\) to month/season \(m+\frac{w-1}{2}\)
4:\(K_{m}\leftarrow\) model trained using \(D_{m}\)
5: Include \(K_{m}\) in \(\mathcal{K}\)
6:return\(\mathcal{K}\)
```  
**Algorithm 1**_WindowTraining_ (monthly/seasonal)  
We illustrate our proposal with the example depicted in Figure 0(a),b. In our example, we assume a window of three months, i.e., \(w=3\). First, we centre the sliding window on January (Figure 0(a)). Our first training dataset is composed of datapoints from December, January, and February, and the model trained with it will be used to predict observations from January. By sliding the window, we can create up to twelve different models (one per month). Figure 0(b) shows an example of a prediction for a datapoint \(d_{m}\) belonging to February. According to the month of the observation to be predicted, the particular model trained when the window was centered on that month (February, in this example) is used to make the prediction.