# Hierarchical Modelling for CO\({}_{2}\) Variation Prediction for HVAC System Operation
## 4 Method: Hierarchical Model for CO\({}_{2}\) Variation Predictions (HMCOVP)
### Time-Series to Image Transformation  
The input represents time-series data of environmental features defined by \(X=\{X_{1},X_{2},...,X_{k}\}\), such that each \(X_{i}\) where \(i\in[1,k]\) describes the time-series data of a single environmental feature. The discussion about the extracted environmental features is provided in the experimental setup. Accordingly, \(X_{i}=\{x_{i1},x_{i2},...,x_{in}\}\), such that \(n\) is the number of observations. To simplify the subsequent equations, \(x_{j}\in X_{i}\) would represent values of a feature \(i\) at timestamp \(j\). The exploratory data analysis showed that a lag time of up to 20 min for each environmental feature can be used to predict the CO\({}_{2}\) concentration changes for a conference room that fits 12 people. As such, there is a need to reflect the existing time correlation in the feature engineering step. Python packages can be used for extracting time-based features such as the Time Series Feature Extraction Library [37] and Time Series FeatuRe Extraction on the basis of the Scalable Hypothesis test [38] (tsfresh). The extraction of hand-crafted features resulting from these two packages requires incorporating domain-specific insights, which are not available for the case under study. Additionally, the large feature space necessitates integrating feature selection or transformation steps. To address the limitations of the hand-crafted extraction of features, DNNs create their own features by the composition of multiple non-linear functions, each representing combinations of the input dataset features. One concern with DNNs, in their crude form, is their inability to model the time aspect, despite the manual process of including lagged versions of the features. Therefore, a feature engineering stage is incorporated to reflect the underlying time correlation between lagged versions of the available variables. [PERSON] and [PERSON] [39] have devised the Gramian Angular Field (GAF) method for the transformation of time series data into a symmetrical 2D matrix. As opposed to other time series-to-image transformations, the resulting GAF image exposes the temporal dependencies between data points in a time series. Towards obtaining GAF images, two steps are followed. In the first step of the transformation, the time series data are normalized between \([0,1]\). The normalization process is conducted in the following equation, whereby \(\tilde{x_{j}}\) is the normalized value:  
\[\tilde{x_{j}}=\frac{x_{j}-min(X_{i})}{max(X_{i})-min(X_{i})} \tag{2}\]  
Figure 2: Methodology Steps. In the second step, the normalized data is transformed into the polar coordinate system that is calculated as follows:  
\[\phi_{j}=\arccos(\hat{x_{j}}),\,0\leq\hat{x_{j}}\leq 1\] \[r=\frac{t_{j}}{N},\,t_{j}\in\mathbb{N} \tag{3}\]  
After obtaining the transformation to polar coordinates for each data point, the next step is to generate a matrix that reflects the data dependencies between the new form of observations. The GAF technique exploits the angular representation by calculating the pairwise trigonometric sum between the points to reflect the temporal correlations. Considering a time frame of \(k\) seconds, such that \(\theta_{j,j+1}=\cos(\phi_{j}+\phi_{j+1})\), the \(k\times k\) GAF matrix is defined as follows:  
\[ \begin{bmatrix}\theta_{0,0}&\theta_{0,1}&\dots&\theta_{0,k-1}\\ \theta_{1,0}&\theta_{1,1}&\dots&\theta_{1,k-1}\\ \vdots&\ddots&\dots&\dots\\ \theta_{k-1,0}&\theta_{k-1,1}&\dots&\theta_{k-1,k-1}\end{bmatrix}  \tag{4}\]  
The GAF matrix fits the requirements of the use case under study. First, it exposes the temporal dependencies present in the original time series as the time increases progressively from top-left to bottom-right. Second, the polar coordinates expose the relative correlations between data points with the help of superposition. Lastly, the time-series information is retained in the GAF matrix, which is beneficial when there is a need to integrate original data in any envisioned process. These original values can be extracted from the diagonal values.