# Electric Load Forecasting Based on Deep Ensemble Learning
## 2 Materials and Methods
### CNN-BiLSTM-RF Anomaly Detection Model
#### 2.2.1 The Convolutional Neural Network Layer  
Convolutional neural network layers are utilized to extract local features from time series data [21]. Through convolution operations and activation functions, CNN can effectively capture the spatial and temporal correlations in the input data. These local features are crucial for anomaly detection in electric load data, as anomalous values often lead to local changes in the data.  
In the convolutional layer, each filter employs the same convolutional kernel to perform convolution operations on the input data from the preceding layer, producing a feature vector [22]. The convolution operation effectively captures the local features of the input data by performing calculations on the input data via a sliding window method. The \(j\)-th output feature vector is described as follows:  
\[x_{j}^{l}=f(\sum_{d}x_{d}^{l-1}*w_{j,d}^{l}+b_{j}^{l}) \tag{1}\]  
where \(x_{j}^{l}\) represents the \(j\)-th output feature vector, denoting the output of the \(j\)-th neuron in the \(l\)-th layer of the convolutional neural network; \(x_{d}^{l-1}\) represents the \(d\)-th input feature vector of the \((l-1)\)th layer, i.e., the output of the \(d\)-th neuron in the \((l-1)\)th layer of the convolutional neural network; \(w_{j,d}^{l}\) represents the weight connecting the \(d\)-th neuron of the \((l-1)\)th layer and the \(j\)-th neuron of the \(l\)-th layer; the bias term for the \(j\)-th neuron in the \(l\)-th layer.  
The input in the convolutional neural network layer consists of preprocessed power load data, represented as a one-dimensional time series. In this series, each timestep corresponds to a power load measurement. The length of the input data is denoted as \"input_length\", and the feature dimension is referred to as \"input_channels\". This paper employs one-dimensional convolutional neural networks (1D CNNs) to process such time  
Figure 1: The structure diagram of the CNN-BiLSTM-RF method.  
series data. The rationale behind using 1D CNNs is their ability to capture local features within the time series. Only a small time window of the input data is considered during a single convolution operation. Such a mode of processing enables the model to detect local patterns and trends within the data more effectively.  
To better capture multi-layered features in the data, the model employs three Conv1D layers stacked together to learn the data features. After each convolutional operation, the ReLU activation function introduces nonlinearity, assisting the neural network in recognizing complex features and patterns. Following the convolution, the extracted features are directed to a pooling layer to simplify their representation. In this study, we utilize the K-Max pooling method. The following formula represents the max-pooling operation:  
\[Y[i,j]=\max_{m,n\in[0,K-1]}X[i\cdot K+m,j\cdot K+n] \tag{2}\]  
where \(Y\) is the output feature map, and \(i\) and \(j\) represent the rows and columns of the output feature map, respectively. \(m\) and \(n\) represent the rows and columns within the pooling window.  
This operation captures the essential feature information from each filter by selecting the top-K maximum values. The purpose of the K-Max pooling operation is to extract the most representative features, allowing the model to understand better the input data's important aspects [23]. In this manner, the most significant features are retained while reducing irrelevant information, thus enhancing the model's performance and accuracy in processing sequence data. After three stacking layers, the feature map is flattened into a one-dimensional vector, which is then processed by the fully connected layer. Lastly, a fully connected dense layer is added, mapping the flattened feature vector to the output space to produce the final output of the convolutional neural network layers.