## 2 Methodology
### Long Short-Term Memory (LSTM)  
The LSTM model is an advanced variant of recurrent neural networks (RNNs) designed for processing sequential data, such as time-series datasets [32; 33; 34]. While traditional RNNs rely on past information to predict future values, they suffer from the vanishing gradient problem, which limits their ability to capture long-term dependencies effectively [35; 36; 37]. LSTM overcomes this limitation by incorporating memory cells that selectively retain or discard information over time, enabling the model to learn long-range dependencies more efficiently than conventional RNNs. LSTM networks utilize three primary gates--the input gate, forget gate, and output gate--to regulate the flow of information, as shown in Figure 1. The input gate controls how much new information is added to the memory cell, while the forget gate determines which information from the previous cell state should be discarded. The output gate generates the final hidden state based on the current cell state. These gates employ sigmoid activation functions (\(\sigma\)) to produce values between 0 and 1, thereby controlling the extent to which information is retained or forgotten. Additionally, the hyperbolic tangent function (tanh) is used to generate candidate values for updating the memory cell. The LSTM operates as follows:  
* Forget gate: determines how much information from the previous cell state \(C_{t-1}\) should be retained, using the previous hidden state \(h_{t-1}\) and the current input \(x_{t}\): \[f_{t}=\sigma\Big{(}W_{f}\cdot[h_{t-1},\ x_{t}]+b_{f}\Big{)}.\] (2)
* Input gate: decides how much new information should be added to the memory cell: \[i_{t}=\sigma(W_{i}\cdot[h_{t-1},\ x_{t}]+b_{i}).\] (3)
* Candidate cell state: computes a potential new memory cell value using the hyperbolic tangent function: \[\widetilde{C}_{t}=\tanh(W_{C}\cdot[h_{t-1},\ x_{t}]+b_{C}).\] (4)  
Figure 1: Structure of the LSTM network, illustrating the three primary gates: input gate, forget gate, and output gate (\(\sigma\): sigmoid activation function, tanh: hyperbolic tangent function, \(x_{t}\): input at time step, \(i_{t}\): output of the input gate, \(f_{t}\): output of the forget gate, \(\widetilde{C}_{t}\): candidate cell state, \(C_{t}\): cell state, \(o_{t}\): output of the output gate, and \(h_{t}\): hidden state). * Memory cell update: updates the memory cell state by combining the forget gate's output with the new candidate value: \[C_{t}=f_{t}\cdot C_{t-1}+i_{t}\cdot\widetilde{C_{t}}.\] (5)
* Output gate: determines the final hidden state \(h_{t}\) based on the updated memory cell state: \[o_{t}=\sigma(W_{o}\cdot[h_{t-1},\ x_{t}]+b_{o}),\] (6) \[h_{t}=o_{t}\cdot\tanh(C_{t}).\] (7)  
In the above equations, each \(b\) represents the bias term for the corresponding gate or cell state (e.g., \(b_{f}\) for the forget gate, \(b_{i}\) for the input gate, \(b_{C}\) for the candidate cell state, and \(b_{o}\) for the output gate). This process is repeated at each time step, allowing the LSTM to effectively capture long-term dependencies in sequential data. To address the challenges of power consumption prediction in time-series data, a customized LSTM model was designed and implemented. This model was tailored to process multi-dimensional input features and generate accurate predictions by learning both short-term and long-term dependencies. Each input sequence comprised 10 consecutive time steps, with 14 features per time step, including:  
* Temporal attributes (year, month, day, hour, and minute);
* Environmental factors (temperature, humidity, wind speed, precipitation, and solar radiation);
* Operational indicators (working day/non-working day indicator, COVID-19 social distancing index, and number of employees present);
* Power consumption data. These features were selected to capture environmental and operational factors affecting energy usage. The LSTM architecture consisted of a single LSTM layer with six hidden units.