# Conditional Temporal Aggregation for Time Series Forecasting Using Feature-Based Meta-Learning
## 3 Proposed Method
### Forecasting Framework  
The proposed framework, summarized in Algorithm 1, is implemented into two phases; the offline and the online phase. The offline phase involves the preparation of the data, the tuning of the meta-learner, and the training process, while the online phase puts in actual use the trained classifier to generate forecasts. The pipeline for implementing the framework is also visualized in Appendix B. The first objective of the framework is to select for each time series of a given data set the most suitable level of temporal aggregation, i.e., the level that maximizes forecasting accuracy. Given a time series of certain frequency, we employ non-overlapping temporal aggregation to transform the data into lower frequencies. From the constructed time series, and depending on whether the data are slow- or fast-moving, we extract the time series features presented in Section 3.1. Then, base forecasts are computed for each aggregation level using a forecasting method of preference. Finally, given a validation set, the forecasts are evaluated using an error measure of choice and the aggregation level that reports the highest accuracy is labeled as the \"right\" class. The aforementioned process is repeated for all the series included in the data set, resulting in a rich set of time series features and their corresponding \"best\" level of temporal aggregation. An illustrative example of the data set \begin{table}
\begin{tabular}{l c} \hline \hline
**Hyperparameter** & **Range** \\ \hline \(N_{iterations}\) & \([10,150]\) \\ \(N_{faces}\) & \([10,200]\) \\ \(LearningRate\) & \((0,1)\) \\ \(FeatureFraction\) & \((0,1)\) \\ \(BaggingFraction\) & \((0,1)\) \\ \(SamplingFrequency\) & \([10,100]\) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Hyperparameters ranges for validation process. preparation stage is presented in Figure 3 for a monthly time series. Having the train set of the meta-learner constructed, we tune the hyperparameters of the classifier as described in Section 3.2 and then train the model using the complete train set. These steps complete the offline phase of the framework. ```
Offline Phase: Data preparation, hyperparameter tuning, and training Inputs :\(D\): Data set \(\{d_{1},d_{2},...,d_{N}\}\) consisting of \(N\) time series. \(F\): Set of functions used for calculating time series features. \(L\): Set of aggregation levels considered for implementing (multiple) temporal aggregation. Output :\(M\): A classifier that, given a set of time series features, estimates the probability that the forecasts at every level \(l\in L\) will be the most accurate. forn = 1 to N:do  Define the periods to be used for producing base forecasts and evaluating their accuracy (ideally, the length of the evaluation period should match the forecasting horizon). Accordingly, split the series into an in-sample and an out-of-sample set of observations. Apply temporal aggregation to the in-sample data to construct \(L\) series. For every level \(l\in L\), calculate time series features using \(F\). At every level \(l\in L\), fit a forecasting model and produce forecasts that cover the evaluation period. Calculate forecast error over the out-of-sample data. Flag the level that results to the most accurate forecasts (labeling). end for  Use the features-label pairs created to construct the train set of the meta-learner. Optional : Tune the hyperparameters of the meta-learner using a validation set. Train the meta-learner. Online Phase: Forecast new time series Inputs :\(M\): The trained meta-learner. X: Data set \(\{x_{1},x_{2},...,x_{K}\}\) consisting of \(K\) time series. Output :\(Y\): Forecasts of the \(K\) time series. forn=1 to K:do  Apply temporal aggregation to construct \(L\) series. For every level \(l\in L\), calculate time series features using \(F\). At every level \(l\in L\), fit a forecasting model and produce forecasts that cover the period being forecast. Produce a vector of probabilities \(p=\{p_{1},p_{2},...,p_{L}\}\) using \(M\).