# Conditional Temporal Aggregation for Time Series Forecasting Using Feature-Based Meta-Learning
## 3 Proposed Method
### Classifier (Meta-Larner)  
In the attempt to develop a meta-learner, we utilize a ML classification model. Classification consists a supervised ML problem, focusing on the accurate assignment of observations (in our case, time series) into certain classes (in our case, temporal aggregation levels). The problem can be either binary, meaning that there are only two possible classes, or multi-class.  
To perform classification, a set of selected features (inputs) is extracted for each observation included in the data set used for training the ML method, along with their respective class (output or label). Then, the method is tasked to identify patterns so that the classes are precisely predicted based on the features available. Ultimately, once the relationships between the classes and the features have been learned, the method can be used to classify observations that were not originally included in the train set. Note that most classifiers do not predict the label per se, but estimate the probability of a class to be the \"right\" one. Therefore, the output of the classifier can be realized as a probabilistic prediction that can be used to identify the class that is presumably \"correct\".  
In the settings of our study, the probabilities will refer to how likely it is for a certain temporal aggregation level to result in the most accurate forecasts. Consequently, selecting the level of the highest probability will suggest forecasting through temporal aggregation, while combing the forecasts produced at all levels with weights that are driven by said probabilities will suggest forecasting through multiple temporal aggregation. Note that, if the lowest temporal aggregation level is identified as \"best\", the classifier will effectively suggest conventional forecasting, i.e., forecasting at the original frequency of the series.  
Although the classifier can be implemented using any ML model of preference, we chose a gradient boosting model due to its high accuracy and low computational cost. Specifically, we employed the Booster model from the _LightGBM_ library for Python, an ML algorithm built on gradient boosting trees that generates multiple independent trees, one at a time, aiming to decrease each time the errors made by the former trained tree.  
LightGBM involves several hyperparameters that can significantly affect its performance. In order to tune them, we apply grid search, an automated method that explores a set of different hyperparameter values and computes the forecasting performance on a validation set to find the most appropriate ones, as defined by an accuracy measure. We focus on the most critical hyperparameters, i.e., the number of boosting iterations (\(N_{iterations}\)), which determines the number of trees to be created (the model generates (\(N_{labels}\times N_{iterations}\)) trees), the maximum number of leaves in each tree (\(N_{tensors}\)), the learning rate, the percentage of features sampled (feature fraction), the percentage of data sampled from the data set without re-sampling (bagging fraction), and the frequency in which the data are being sampled during the iterations (sampling frequency).  
The ranges from which the hyperparameter values were randomly sampled in our experiments are presented in Table 1. In our case, the validation set consisted of the last \(h\) observations of the time series train set, with \(h\) being the forecasting horizon. However, once the hyperparameters were identified, the classifier was re-trained using the complete train set.