# Energy Analysis in Green Building via Machine Learning: A Case Study in a Hospital
## 2 Materials and Methods
### Equations for Different Types of Long Short-Term Memory for Time Series Forecasting  
Vanilla LSTM is considered the basic type among LSTM types. The equations for a vanilla LSTM cell involve several computations to update and output information. These equations can be seen in Equations (1)-(5). In these equations, i is the input gate, f is the forget gate, c is the cell state, o is the output gate, and h is the hidden state. The input gate controls how much information from the current input should be stored in the cell state. The forget gate controls how much of the previous cell state should be forgotten. The cell state equation combines the information from the forget gate and the input gate. The output gate controls how much of the cell state should be exposed as output. The hidden state equation computes the output of the LSTM cell, which is a filtered version of the cell state [26]. \[\mathrm{i_{t}}=\sigma(\mathrm{W_{ix}x_{t}}+\mathrm{W_{in}h_{t-1}+b_{i}}) \tag{1}\]  
\[\mathrm{f_{t}}=\sigma(\mathrm{W_{fx}x_{t}}+\mathrm{W_{In}h_{t-1}+b_{f}}) \tag{2}\]  
\[\mathrm{c_{t}}=\mathrm{f_{t}}^{*}\mathrm{c_{t-1}}+\mathrm{i_{t}}^{*}\mathrm{ tanh}(\mathrm{W_{cx}x_{t}}+\mathrm{W_{ch}h_{t-1}+b_{c}}) \tag{3}\]  
\[\mathrm{o_{t}}=\sigma(\mathrm{W_{ox}x_{t}}+\mathrm{W_{oh}h_{t-1}+b_{o}}) \tag{4}\]  
\[\mathrm{h_{t}}=\mathrm{o_{t}}^{*}\mathrm{tanh}(\mathrm{c_{t}}) \tag{5}\]  
Here, xt is the input at time step t, ht-1 is the hidden state of the previous time step, ct-1 is the cell state of the previous time step, W's are weight matrices, b's are bias vectors, and \(\sigma\) is the sigmoid function. (*) represents element-wise multiplication. For stacked LSTM, equations remain almost the same. There is only one minor change in the cell state equation. This can be seen in Equation (6). \[\mathrm{c_{t}}=\mathrm{f_{t}}^{*}\mathrm{c_{t-1}}+\mathrm{i_{t}}^{*}\mathrm{ tanh}(\mathrm{W_{c}}[\mathrm{h_{t-1}},\mathrm{h_{t}}]+\mathrm{b_{c}}) \tag{6}\]  
The most important difference in this type is the recalculation and combining of the equations for each layer. The minor change in the equations is also a reference to this difference. The bidirectional LSTM is an extension of the standard LSTM model that processes input sequences in both forward and backward directions. This enables the model to capture dependencies from the past, as well as future context. In this type, two different outputs occur. These are forward LSTM and backward LSTM. The bidirectional LSTM combines the outputs of both the forward and backward LSTMs for each time step to obtain the final output sequence. The mathematical equations for a forward bidirectional LSTM are the same as vanilla LSTM. Backward bidirectional LSTM equations are almost the same. The only change is that the parts with t\(-\)1 values in the equations become t+1. For instance, the cell state equation of backward bidirectional LSTM can be seen in Equation (7). \[c_{t}=f_{t}{}^{*}c_{t+1}+i_{t}{}^{*}tanh(W_{cv}x_{t}+W_{ch}h_{t+1}+b_{c}) \tag{7}\]  
In this way, by continuing the operations in the opposite direction, provision is made. By using t+1 instead of t\(-\)1 in all equations, the reverse calculation is made. The combination of Convolutional Neural Networks (CNNs) and LSTM networks is often used in tasks where the input data have both spatial and temporal dependencies, such as video classification or time series forecasting. The architecture typically involves using CNNs to extract spatial features from the input data, followed by an LSTM layer to capture temporal dependencies in the feature representations extracted by the CNN. This model is called CNN-LSTM. In the CNN-LSTM model, there are three steps to produce the final output. These steps are CNN, LSTM, and final output layer steps. The CNN layers involve convolutions and pooling operations. With CNN, the output feature map can be calculated as in Equation (8). Here, X is input, W are filters and b are biases to pass the input through one or more convolutional layers.