Power load prediction method, system and equipment based on neural network, and medium
By combining convolutional neural networks and bidirectional long and short-term memory neural networks, and using whale optimization algorithm to optimize hyperparameters, the shortcomings of existing power load prediction methods in capturing spatiotemporal characteristics and multi-factor connections are achieved, and higher prediction accuracy is achieved and stability.
Patent Information
- Application Number
- CN202411083798.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-11-26
AI Technical Summary
Existing power load prediction methods are difficult to accurately capture the spatial and temporal characteristics and multi-factor intrinsic relationships in power load data, resulting in low prediction accuracy. Traditional methods rely too much on manual experience, which may lead to prediction deviations and reduced accuracy when facing large changes.
A deep learning model based on the combination of convolutional neural network (CNN) and bidirectional long and short-term memory neural network (BiLSTM) was used, and a set of CNN-BiLSTM deep learning model was designed using the Whale Optimization Algorithm (WOA). For power load prediction.
It improves the accuracy and stability of power load prediction, improves the robustness and prediction accuracy of the model, making the method more operable in practical applications.
Smart Images

Figure CN119029847A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of power load forecasting, and in particular relates to a power load forecasting method, system, equipment and medium based on a neural network. Background Art
[0002] China's rapid economic growth and urbanization have driven the growth of electricity demand, and have put forward higher requirements for the efficiency and safety of the power industry. Accurately predicting power load helps power companies achieve stable power supply, ensure power supply quality, improve economic benefits, and protect social energy security. Power generation in power plants is synchronized with user power consumption. Since it is difficult to store large amounts of electricity, it is necessary to keep power generation and power consumption in a dynamic balance to achieve efficient operation of the power grid. Serious imbalances in supply and demand may lead to safety accidents and huge economic losses in the power system. Therefore, it is necessary to adjust the power supply and demand structure in a timely manner to ensure the safe and stable operation of the power system.
[0003] Due to the randomness of charge changes, an effective solution is to accurately predict the power load. The core goal of power supply is to ensure a precise balance between power generation and load demand, thereby ensuring the safe and efficient operation of the power grid. When the power load demand exceeds the power generation, the power company needs to increase the output power of the generator set or allocate power from other power grids to meet this demand. Conversely, when the power load demand is less than the power generation, in order to avoid energy waste, you can choose to stop the operation of some generators or allocate excess power to other power grids. In order to ensure the long-term safe and stable operation of the power grid, reduce costs and make scientific decisions, it is necessary to improve the accuracy of power load forecasting, so related research and application work need to be continued.
[0004] The research on power load forecasting aims to find accurate forecasting methods to improve forecasting accuracy by analyzing historical data to mine internal laws. Natural climate and electricity prices, etc., may cause power load data to be complex and changeable. Traditional forecasting methods are limited and cannot fully explore the internal connections between multiple factors in load data, making it difficult to achieve satisfactory forecasting results. Improving the accuracy of power load forecasting is crucial to reducing the cost of power grid operation, because a 1% increase in forecast error will significantly increase costs. The focus of this paper is to explore various methods and strategies to improve the accuracy of power demand forecasting through research, thereby ensuring the efficient operation of the power system.
[0005] With the development of power grids, the accumulation of a large amount of power load data provides rich original data for prediction research. In this context, the development of big data analysis technology and the application of artificial intelligence technology are becoming more mature, providing technical support for prediction research. Traditional prediction algorithms show certain difficulties in mining the intrinsic characteristics of data, but prediction models based on deep learning can achieve high-precision prediction. The complexity of power load changes makes it difficult for a single model to effectively capture this relationship, and the prediction accuracy is low. The existing empirical prediction methods are divided into two categories, namely historical experience prediction method and trend extrapolation prediction method. Due to the lack of objective theoretical basis and scientific methods, the subjectivity and limitations of historical experience prediction method limit the applicability of this method in long-term prediction and large-scale power system prediction. When using trend extrapolation method, when the volatility of load data increases, the prediction error of this method will also increase accordingly. The composition of traditional prediction methods is: regression analysis method, time series method, gray theory method and Kalman filtering, but it relies too much on manual experience, which may lead to prediction deviation when facing large change factors, and when the data is relatively scattered, the prediction accuracy drops sharply. Summary of the invention
[0006] The purpose of the present invention is to provide a method, system, device and medium for power load forecasting based on neural network to solve the problems existing in the above-mentioned prior art.
[0007] To achieve the above object, the present invention provides a method for power load forecasting based on a neural network, comprising:
[0008] Acquire historical data of the power system, wherein the historical data includes power load values and power load influencing factor data at different time points in the power system;
[0009] Constructing a power load forecasting model, wherein the power load forecasting model includes a convolutional layer, a pooling layer, a bidirectional LSTM layer, and a fully connected layer connected in sequence;
[0010] Extracting hyperparameters included in the power load forecasting model, training the power load forecasting model based on historical data, and using the loss of the training result as the fitness value corresponding to each of the hyperparameters;
[0011] Based on the fitness value corresponding to each hyperparameter and in combination with the whale optimization algorithm, each hyperparameter is optimized to obtain the optimal hyperparameter;
[0012] Applying the optimal hyperparameters to the power load forecasting model to obtain a power load forecasting model after parameter optimization;
[0013] The power load prediction of the power system is performed based on the power load prediction model after parameter optimization to obtain a power load prediction result.
[0014] Optionally, before training the power load forecasting model based on historical data, the historical data is also subjected to missing value processing, outlier processing, normalization and data reconstruction to obtain preprocessed historical data, and the power load forecasting model is trained based on the preprocessed historical data.
[0015] Optionally, the power load forecasting model is trained based on historical data, specifically including:
[0016] Acquire training data, wherein the training data includes historical data and corresponding prediction labels, wherein the prediction labels are power load prediction values of the historical data after a preset time period;
[0017] An initial power load forecasting model is constructed, the training data is input into the initial power load forecasting model, local features of the training data and historical data are extracted through the convolution layer to obtain local features, the local features are pooled through the pooling layer, and the pooled local features are input into the bidirectional LSTM layer to extract spatiotemporal features to obtain spatiotemporal features; the local features and the spatiotemporal features are input into the fully connected layer for classification prediction, and training is performed with the goal of minimizing the loss between the initial training result after classification prediction and the prediction label corresponding to the historical data to obtain a trained power load forecasting model.
[0018] Optionally, the process of obtaining the predicted label specifically includes:
[0019] The historical data is used as input features, and the power load is predicted after a preset time period based on the sliding window method in combination with the input features in the window to obtain the power load prediction value after the preset time period, and the power load prediction value after the preset time period is used as the prediction label of the historical data.
[0020] Optionally, based on the fitness value corresponding to each of the hyperparameters, the whale optimization algorithm is combined to perform parameter optimization on each of the hyperparameters to obtain the optimal hyperparameter, specifically including:
[0021] An initial population is constructed based on a preset population size, each of the hyperparameters and the corresponding fitness values, and each hyperparameter in the initial population is iteratively updated multiple times based on the whale optimization algorithm. In each iterative update process, the fitness value corresponding to each of the hyperparameters is calculated, and the initial population is updated based on the fitness value corresponding to each of the hyperparameters, until the number of iterations reaches a preset number of iterations, and then the optimal hyperparameters are output.
[0022] A method for predicting electric load based on a neural network, comprising:
[0023] A data acquisition module is used to obtain historical data of the power system, wherein the historical data includes power load values and power load influencing factor data at different time points in the power system;
[0024] A parameter optimization module is used to construct a power load prediction model, wherein the power load prediction model includes a convolutional layer, a pooling layer, a bidirectional LSTM layer and a fully connected layer connected in sequence; extract the hyperparameters included in the power load prediction model, train the power load prediction model based on historical data, and use the loss of the training result as the fitness value corresponding to each hyperparameter; perform parameter optimization on each hyperparameter based on the fitness value corresponding to each hyperparameter in combination with a whale optimization algorithm to obtain the optimal hyperparameter; apply the optimal hyperparameter to the power load prediction model to obtain the power load prediction model after parameter optimization;
[0025] The power load forecasting is used to perform the power load forecasting of the power system according to the power load forecasting model after parameter optimization to obtain the power load forecasting result.
[0026] An electronic device includes a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the neural network-based power load forecasting method.
[0027] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements a neural network-based power load forecasting method.
[0028] The technical effects of the present invention are:
[0029] The present invention captures long-term dependencies through a bidirectional long short-term memory neural network and fully exploits the spatiotemporal characteristics of power load data. In order to further improve the robustness and accuracy of the model, the whale optimization (WOA) algorithm is introduced to optimize the CNN-BiLSTM model parameters. A complete power load forecasting solution based on the CNN-BiLSTM deep learning model is designed, which has good prediction accuracy and stability, making the method more operational in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0031] Figure 1 is a model flow chart in an embodiment of the present invention;
[0032] Figure 2: is a flowchart of the WOA algorithm principle in an embodiment of the present invention;
[0033] Figure 3 is a code flow chart of the WOA algorithm in an embodiment of the present invention;
[0034] Figure 4 is the prediction result after WOA optimization in the embodiment of the present invention;
[0035] Figure 5 is a prediction graph of each model in the embodiment of the present invention;
[0036] Figure 6 This is a flow chart of power load prediction in an embodiment of the present invention. DETAILED DESCRIPTION
[0037] Various exemplary embodiments of the present invention will now be described in detail. This detailed description should not be considered as limiting the present invention, but should be understood as a more detailed description of certain aspects, features, and embodiments of the present invention.
[0038] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0039] Embodiment 1
[0040] like Figure 1 - Figure 6 As shown, in this embodiment, a method for power load forecasting based on a neural network is provided, including: obtaining historical data of the power system, the historical data including power load values and power load influencing factor data at different time points in the power system; constructing a power load forecasting model, the power load forecasting model including a convolutional layer, a pooling layer, a bidirectional LSTM layer and a fully connected layer connected in sequence; extracting the hyperparameters included in the power load forecasting model, training the power load forecasting model based on historical data, and using the loss of the training result as the fitness value corresponding to each of the hyperparameters; optimizing the parameters of each of the hyperparameters based on the fitness value corresponding to each of the hyperparameters in combination with the whale optimization algorithm to obtain the optimal hyperparameters; applying the optimal hyperparameters to the power load forecasting model to obtain the power load forecasting model after parameter optimization; executing power load forecasting of the power system based on the power load forecasting model after parameter optimization to obtain a power load forecasting result.
[0041] With the increasing complexity and uncertainty of the power system, accurate power load forecasting is of great significance in ensuring the smooth operation of the power system, coping with system fluctuations, avoiding supply and demand imbalances, and reducing operating costs. Since traditional forecasting methods are limited by the amount of data, computing power, and model complexity, it is difficult to capture the nonlinear characteristics and spatiotemporal correlation of power loads. This embodiment proposes a power load forecasting method that combines a convolutional neural network-bidirectional long short-term memory neural network (CNN-BiLSTM) and a whale optimization algorithm (WOA) to improve forecasting accuracy and stability.
[0042] Taking advantage of the convolutional neural network in extracting local features of power data, the bidirectional long short-term memory neural network is used to capture long-term dependencies and fully explore the spatiotemporal characteristics of power load data. In order to further improve the robustness and accuracy of the model, the whale optimization (WOA) algorithm is introduced to optimize the CNN-BiLSTM model parameters. A complete power load forecasting solution based on the CNN-BiLSTM deep learning model is designed, covering data preprocessing, model design, training and evaluation, and performance indicator analysis, making this method more operational in practical applications.
[0043] The experimental results show that the CNN-BiLSTM model optimized by WOA outperforms other methods, including the original CNN-BiLSTM model, BP neural network and BiLSTM model, in terms of fitting degree and prediction accuracy. This result verifies the effectiveness of the solution proposed in this embodiment in power load forecasting.
[0044] This embodiment mainly includes the following steps:
[0045] (1) Study the basic implementation principles of deep learning models based on time series analysis. With the help of online reference materials, study the ideas, architecture and principles of the CNN-BiLSTM hybrid model for power load forecasting in time series forecasting.
[0046] (2) The required data set including CNN-BiLSTM model data for training, verification and testing is produced through historical power load data. This embodiment combines deep learning with power load data to construct a computer intelligent prediction and monitoring method for power load based on probability estimation and artificial intelligence technology. According to the time series characteristics of power load, a single feature prediction scheme is formed and a model is constructed using the CNN-BiLSTM model. The network is trained by inputting the processed power load data set, and the trained network is tested.
[0047] (3) Optimize and improve the constructed prediction algorithm model to improve the prediction accuracy. When using the prediction algorithm to predict power load, the whale optimization strategy (WOA) is used to tune the model hyperparameters. The learning rate and batch size of the CNN-BiLSTM model are adjusted through the WOA algorithm to improve the prediction accuracy of the model.
[0048] (4) Carry out final debugging, and prove the usability and practicality of the program based on the test results of the power load forecasting model and the whale optimization algorithm, and then illustrate the feasibility of the power load forecasting program designed based on multimodal features.
[0049] (5) Perform prediction analysis on power load data in actual applications to verify the performance of the model in actual scenarios. Based on the prediction results and true values of actual power load data, the performance of the prediction model is evaluated using evaluation criteria such as R2, MAE, RMSE, and MAPE to prove the effectiveness of the constructed power load prediction system based on multimodal features in actual applications.
[0050] With the growth of global energy demand, the stable operation of power systems and the rationality of energy distribution are becoming increasingly important. In power systems, load forecasting is one of the key tasks, which is of great significance for grid dispatching, power market transactions, and the effective use of renewable energy. However, the accuracy of load forecasting is affected by many factors, such as the accuracy of historical load data, meteorological conditions, seasonal changes, holidays, etc. The development of accurate and efficient power load forecasting models is an important requirement for power system management, which is of great significance for optimizing power resource allocation and improving system stability.
[0051] Power load forecasting is actually based on the operating characteristics of the power load system, natural environment, social conditions and other factors, using mathematical methods to establish the relationship between historical load data and future load values, so as to infer the value of the power load at a certain moment in the future.
[0052] The characteristics of power load forecasting are divided into four categories, namely uncertainty, dependence, time correlation, and multiple options. Since load forecasting has uncertainty and dependence, it is necessary to analyze and make conditional assumptions based on multiple possible situations when forecasting. By formulating multiple options, the multiple options selectivity of the forecast is reflected.
[0053] The data of power forecast is affected by many factors, including meteorological factors, economic factors and natural disasters. This embodiment focuses on the ultra-short-term power load analysis. The influence of these factors is very small for ultra-short-term analysis, so they are not taken into consideration in this embodiment.
[0054] This embodiment focuses on ultra-short-term power load forecasting, using historical load data to predict the power load value in the future (e.g., 15 minutes later). This embodiment will improve the prediction accuracy by building a CNN-BiLSTM model and using the whale optimization algorithm (WOA) for hyperparameter optimization.
[0055] Neural network model: Convolutional neural network (CNN) emerged as a complex artificial neural network for two-dimensional input data. In this network, each layer contains multiple two-dimensional panels, which contain a large number of independent neurons. Neurons are connected between adjacent layers, while neurons in the same layer are not connected. Based on the inspiration of time-delay neural networks (TDNNs), convolutional neural networks (CNN) have significant advantages in processing speech, time series and image signals, mainly due to their unique characteristics. CNN reduces the computational difficulty in the time dimension by adopting a shared weight strategy, making it an ideal choice for processing speech and time series signals. Secondly, the shared weight layout makes CNN closer to biological neural networks in structure, which can optimize model performance by adjusting the depth and width of the network. In addition, CNN shows excellent potential in processing natural images with statistical consistency and local correlation, effectively capturing features in images. Compared with fully connected networks, the learning process of CNN is simpler, and model training becomes more efficient due to its fewer network connections and weight parameters.
[0056] Bidirectional LSTM forms the second half of the CNN-BiLSTM architecture. BiLSTM expands on the original LSTM network, allowing hidden layer states to recurse and feed back from both the past and future directions to more effectively mine implicit relationships in time series data. By mining the intrinsic connections between current data and past and future data, BiLSTM improves the model's prediction accuracy and data utilization.
[0057] Compared with unidirectional LSTM, BiLSTM has two loop paths: forward and reverse. When processing time series, BiLSTM considers both sequential information from the past to the future and reverse information from the future to the past. This enables BiLSTM to combine independent hidden layer states of the past and the future when processing time series data, thereby more effectively capturing the temporal characteristics of the data.
[0058] When forecasting power load, different methods need to be selected according to the length of the forecast period. Analyzing the causes of errors and selecting appropriate evaluation indicators are important for optimizing models and improving forecast accuracy. In practical applications, appropriate forecasting methods and evaluation indicators can be selected according to specific needs and data characteristics to achieve more accurate power load forecasting. This helps to better manage power resources and improve energy efficiency.
[0059] This example describes in detail the principles and characteristics of prediction methods such as convolutional neural network (CNN), recurrent neural network (RNN) and bidirectional long short-term memory network (BiLSTM). Evaluation indicators such as root mean square error (RMSE), mean absolute percentage error (MAPE), mean absolute error (MAE) and determination coefficient (R2) are discussed. In the subsequent experimental part, according to actual needs and data characteristics, appropriate prediction methods and evaluation indicators will be selected to achieve more accurate power load forecasting.
[0060] Based on the CNN-BiLSTM model construction process:
[0061] Problems with power load forecasting. Power demand forecasting is a key task in the power system. It aims to predict the power system load at a specific time or period in the future, and provide a basis for the operation, planning, dispatching and management of the power system. Accurate demand forecasting helps improve the efficiency of power resource use, reduce operating costs, ensure the stable and reliable operation of the power system, and safeguard social and economic development. Ultra-short-term power demand forecasting focuses on load changes in a relatively short period of time in the future, and is generally used to meet real-time dispatching and optimization requirements.
[0062] Factors that affect electricity demand include time factors, weather conditions, specific days, electricity price factors, and socio-economic factors. Time factors are the key influencing factors, involving daytime and nighttime, seasonal changes, weekdays and weekends. The electricity demand in these different time periods varies significantly because the electricity demand and electricity consumption habits vary in different time periods. Weather conditions, such as temperature, humidity, wind speed, etc., also have a great impact on electricity demand. In hot or cold weather, the use of air conditioning and heating equipment will lead to a significant increase in electricity demand.
[0063] Specific dates, such as holidays and non-holidays, emergencies, etc., can also cause significant changes in electricity demand. During holidays, residential and commercial electricity demand may change, which in turn affects electricity demand. In addition, electricity prices and socio-economic development also have an impact on electricity demand. With economic growth and improved living standards, electricity demand continues to rise. Electricity price fluctuations may affect consumers' electricity habits, which in turn affects electricity demand.
[0064] In order to predict electricity demand more accurately, this embodiment uses a deep learning model based on CNN-BiLSTM for ultra-short-term electricity demand forecasting. The model integrates convolutional neural network (CNN) and bidirectional long short-term memory network (BiLSTM) to capture the time series laws and characteristics in electricity demand data. Compared with traditional methods and other neural network models, the CNN-BiLSTM model has obvious advantages in processing data with time series laws.
[0065] The electricity demand forecasting process usually includes five stages: collecting and organizing historical data, building a forecasting model, conducting experiments and optimization, evaluating model performance, and applying the forecasting model to forecast future loads. In this embodiment, historical electricity demand data was collected and organized, and a deep learning model based on CNN-BiLSTM was designed and constructed. Through continuous experiments and optimization, the prediction accuracy of the model was improved. Subsequently, various evaluation indicators (such as R2 score, mean square error (MSE), mean absolute error (MAE), and mean percentage error (MAPE)) were used to evaluate the model performance. The optimized model is used to predict future electricity demand.
[0066] Although this embodiment mainly focuses on ultra-short-term power demand forecasting with a single feature, in practical applications, it is possible to further consider introducing other relevant features, such as meteorological data, holiday information, etc., to improve the accuracy and robustness of the forecasting model. This embodiment provides an effective solution for ultra-short-term power demand forecasting, which is helpful for the operation and management of the power system.
[0067] Ultra-short-term data preparation and processing: In this embodiment, the historical data set mainly includes measurement values and meteorological conditions at different time points. Each data set is stored in a comma separated value (CSV) format to facilitate subsequent data processing and analysis.
[0068] The dataset covers multiple variables. Columns prefixed with "T" (such as T0000, T0015, etc.) represent different time points with an interval of 15 minutes from T0000 (00:00) to T2345 (23:45). The values at these time points represent a certain measurement value at a specific moment, so most of the data in the original data are power load values at a time point. By analyzing these measurement values, we can study their changing patterns within a day and their correlation with other variables.
[0069] In addition to the time point measurement values, the data set also contains variables related to meteorological conditions, such as maximum temperature (℃), minimum temperature (℃), average temperature (℃), relative humidity (average) and rainfall (mm). These variables provide information for daily climate characteristics, which helps to understand the impact of meteorological conditions on measurement values. In this embodiment, these meteorological condition variables are not analyzed. Although they may have a certain impact on the ultra-short-term power load forecast results, their impact is minimal compared to other measurement values. Although there is no data on meteorological conditions, the accuracy of this embodiment is still very accurate. Therefore, this embodiment mainly focuses on the measurement values closely related to the power load in order to more focus on the relationship between power load and time.
[0070] In the dataset, each record starts with a date value in the format of YYYYMMDD. This representation method helps to organize the data in chronological order and consider time correlation during analysis.
[0071] To ensure the accuracy and completeness of the data, the data was cleaned and preprocessed before processing the data set. This mainly includes filling missing values, checking outliers, and normalizing the data. These steps can improve data quality, lay the foundation for subsequent data analysis and modeling processes, and thus reduce potential analysis and modeling errors.
[0072] Data preprocessing: In actual historical charge data, there are certain errors in the charge data. The reasons are usually various. It may be that data congestion leads to accumulation and a large amount of data loss, or some reason produces incorrect data that cannot be repaired, and sudden accidents lead to charge data missing or jump. Therefore, data preprocessing plays a key role in the entire model building process. Without data preprocessing, there is no way to clean the dirty data in the data. The preprocessing steps include data cleaning and normalization, which aim to eliminate noise and outliers in the data set so that the model can better learn the underlying rules.
[0073] There may be missing values in the actual data, which may affect the training and prediction results of the model. By filling in missing values or using interpolation methods, the data set will become more complete, thereby improving the model performance.
[0074] Loading data and missing value processing: This embodiment focuses on ultra-short-term power load forecasting. In practical applications, power load data may have missing values. The reasons for these missing values are diverse and will also affect the model prediction effect. Therefore, these missing values need to be processed to ensure the integrity and continuity of the data. You can use the Pandas library to read data and fill NaN values in the data set. In the code implementation of this embodiment, the forward filling method (method = 'pad') is chosen to handle missing values, that is, to replace missing values with the value of the previous data point. This processing method is simple and efficient, while maintaining the continuity of the data. The first few columns of the data set contain power load values. Only this part of the data needs to be retained, and other non-related information is ignored.
[0075] Data reconstruction: The power load values in the original dataset are stored in the form of multidimensional arrays, which may increase the computational complexity because multidimensional arrays require additional indexing and traversal operations. In addition, in some cases, multidimensional arrays may lead to reduced memory efficiency because unused memory space may need to be skipped when accessing its elements. For the power load forecasting problem, a reasonable data representation and storage method is crucial for model training and performance. Converting a multidimensional array to a one-dimensional array can simplify data processing and analysis tasks because a one-dimensional array provides a simple linear index structure for easy traversal and access. In addition, the continuous storage of one-dimensional arrays in memory is conducive to improving memory efficiency and access speed. By converting the data into a one-dimensional array and storing it as a DataFrame, data exploration, preprocessing, and feature engineering operations can be more convenient, which is conducive to improving the solution effect of the power load forecasting problem.
[0076] Data partitioning: In the data processing process, a key step is to divide the data set into a training set, a validation set, and a test set. The significance of data partitioning is to provide data sets at different stages for machine learning models to facilitate training, verification, and evaluation of model performance. Dividing the data set into training sets, validation sets, and test sets helps prevent overfitting and ensures that the model has good generalization ability on unseen data. The role of the training set is to train the model, adjust the weights and biases of the model so that it can capture the potential laws in the data. The validation set is used to evaluate the performance of the model during the training process, and can be used for model selection, hyperparameter adjustment, and prevention of overfitting. During the training process, the model is adjusted and optimized according to the performance on the validation set, and the test set is used to evaluate the generalization ability of the model on unseen data after the model training and verification are completed. The performance indicators on the test set can be used as a reference for the final performance of the model. In this embodiment, the entire data set is divided into 8:1:1 ratios to ensure that the model has enough data to learn during the training process, while leaving a portion of the data for verification and testing. This helps to evaluate the true performance of the model in the problem of power load forecasting and improve the reliability of the model.
[0077] Data normalization: The significance of data normalization is to convert data with different units or ranges into data with consistent units or ranges. This process can reduce the impact of dimensional differences between different features and improve the convergence speed and performance of the model. Normalization usually scales the original data to a smaller range so that different features have similar influence in the calculation process. For the problem of power load forecasting, data normalization is of great significance to model training and performance. Power data usually has different dimensions, such as power, voltage, and current, and there may be large differences between these dimensions. If normalization is not performed, the model may be affected by these differences during training, resulting in slow convergence and even failure to achieve the desired prediction effect. This embodiment uses the MinMaxScaler class of the scikit-learn library to normalize the data and scale the data to the range of [0,1]. This processing method helps to train the model more effectively and improve the convergence speed and performance of the model. The normalized data has similar dimensions, which helps the model better capture the potential laws in the data and improve the accuracy of power load forecasting.
[0078] Sliding window to construct input features and labels: The significance of sliding window to construct input features and labels is to use historical data of a certain length to predict future data. This method can help the model capture the time series characteristics and correlations in the data, thereby improving the prediction performance. The sliding window method is of great significance for the problem of power load forecasting. Power load data usually has time correlation, that is, past data may have a certain predictive ability for future data. By constructing a sliding window, historical data can be used as feature input to predict future power load values. This method helps to improve the model's predictive ability for time series data, thereby improving the accuracy and stability of power load forecasting. When building the model input features and labels, the sliding window method is used to use the load characteristics of the first 96 sampling points to predict the power load value of the 97th point. This setting can help the model capture the time series characteristics and correlations in the power load data, thereby improving the prediction performance. By applying the sliding window method to the problem of power load forecasting, the model can better understand and predict the changing trend of power load, thereby improving the accuracy of the prediction results.
[0079] CNN-BiLSTM model construction: The significance of model construction is to design a suitable model structure according to the data characteristics and task requirements, so as to learn the potential laws in the data and realize the prediction task. By selecting the appropriate neural network structure, activation function, loss function and optimizer, the prediction performance of the model can be improved. In the problem of power load forecasting, the purpose of model construction is to design a model that can capture the time series characteristics and correlations in the power load data. After the data preprocessing is completed, this embodiment constructs a deep learning model based on CNN-BiLSTM for power load forecasting. Convolutional neural networks are good at extracting local features and capturing short-term laws in power load data; bidirectional long short-term memory networks analyze historical and future data, which helps to reveal long-term dependencies in power load data. This model combines the advantages of convolutional neural networks (CNN) and bidirectional long short-term memory networks (BiLSTM) to achieve more accurate time series forecasting. This section will discuss the model construction process in detail, including the design of model structure, loss function, optimizer, etc., as well as the performance of the model on training and test sets.
[0080] Define a create_cnn_bilstm function to build a deep learning model. The function requires two parameters, namely the learning rate lr and the batch size batch_size. The learning rate is used to adjust the step size of the optimizer during the gradient descent process, and the batch size specifies the number of samples used by the model in each iteration during the training process. The model consists of multiple convolutional layers, pooling layers, bidirectional LSTM layers, and fully connected layers, and is linearly stacked through the Keras Sequential model container. The model flow chart is as follows Figure 1 shown.
[0081] CNN part: Add a 1D convolutional layer with 32 filters, kernel size 3, stride 1, and ReLU activation function. This convolutional layer is responsible for extracting local information from the input features. The role of CNN is mainly reflected in the setting of the convolutional layer. Next, add a max pooling layer with a pooling window size of 2 and a stride of 1. Pooling layers are used to reduce the feature dimension and reduce the amount of calculation. Then, add a second convolutional layer with 64 filters, kernel size 2, stride 1, and ReLU activation function. This convolutional layer further extracts feature information and captures higher-level local patterns. Add another max pooling layer with a pooling window size of 3 and stride 1. Pooling layers can also reduce the risk of overfitting. By reducing the number of features, pooling layers can limit the complexity of the model, thereby reducing the possibility that the model will overfit the data on the training set. This helps improve the generalization ability of the model on the test set. These convolutional and pooling layers together form the CNN part, which is responsible for capturing short-term regularities in the power load data.
[0082] BiLSTM part: Next, add a bidirectional LSTM layer with 10 neurons and ReLU activation function. This layer is responsible for capturing long-term dependencies in time series data. The role of BiLSTM in the code is mainly reflected in this bidirectional LSTM layer. Bidirectional LSTM can learn features from both past and future data, which helps to reveal long-term dependencies in power load data.
[0083] Fully connected layer: Add a fully connected layer with 5 neurons and ReLU activation function to integrate the feature information from the convolutional layer and the bidirectional LSTM layer. Finally, add an output layer with only one neuron and no activation function. This neuron is responsible for outputting the predicted power load value.
[0084] The model compilation process includes the selection of optimizers and loss functions. In this embodiment, the Adam optimizer with dynamically adjusted learning rate and mean square error (MSE) loss function are selected. Dynamically adjusting the learning rate is an adaptive optimization strategy that can automatically adjust the learning rate according to performance indicators during training. This helps to converge quickly with a larger learning rate at the beginning of training, and then gradually reduce the learning rate when the training is close to convergence to obtain a more accurate solution. The advantages of dynamically adjusting the learning rate include increasing the model convergence speed, reducing oscillation phenomena and improving the final performance of the model.
[0085] After defining the model structure, you need to set the model's training parameters, such as the learning rate (lr) and batch size (batch_size). In addition to these parameters, there are other parameters that may need to be adjusted, such as the number of iterations (epochs) and the validation set ratio (validation_split). The number of iterations needs to balance training time and model performance. A larger number of iterations may enable the model to learn data features better, but it may also lead to overfitting and longer training time. The validation set ratio can be set between 10% and 20% to monitor the generalization ability of the model during training and can be used as a basis for adjusting hyperparameters (such as learning rate, batch size, etc.). These parameters can be set in the input parameters of the create_cnn_bilstm function.
[0086] After the above steps, a deep learning model based on CNN-BiLSTM was successfully constructed for power load forecasting. In subsequent experiments, this model will be used for training and forecasting, and its performance will be evaluated.
[0087] After the model is built, it needs to be trained and evaluated. During the training process, the model will continuously adjust the weights to minimize the loss function, thereby improving the accuracy of the model in predicting power load. This section will introduce the model training process, performance evaluation method and experimental results in detail.
[0088] (1) Training model: The significance of model training is to adjust the weights and parameters of the model by learning the training data, so that the model can accurately predict the power load in practical applications. The training process enables the model to learn the relationship between the power load and various influencing factors, and improve the prediction accuracy. Model training is crucial to solving the power prediction problem. Model training requires the preparation of appropriate training data, including training features and corresponding labels. These data are the results of preprocessing and feature engineering, which help to reveal the relationship between the power load and various influencing factors. During the training process, the model parameters are gradually adjusted to improve the prediction effect. During the training process, the performance of the model on unknown data can also be observed so as to optimize and adjust it in practical applications. In this embodiment, the CNN-BiLSTM model is used to predict the power load. Training data needs to be prepared, including training features x_train and corresponding labels y_train.
[0089] The following is a detailed description of the training features x_train and the corresponding labels y_train:
[0090] Training features x_train:
[0091] Data sources: historical power load data and other factors that may affect power load.
[0092] Preprocessing: The raw data undergoes preprocessing steps such as normalization, missing value processing, and outlier processing to ensure data quality.
[0093] Feature Engineering: Generate time series samples through the sliding window method. For example, the data of the past 24 hours can be used as the input features of a sample, and the size of the sliding window can be adjusted according to the actual situation.
[0094] The corresponding labels y_train:
[0095] Data source: Historical power load data.
[0096] Generation method: For each input feature sample, the corresponding label is the power load value after the time period of the input feature. For example, if the input feature is data from the past 24 hours, the corresponding label is the power load value of the 25th hour in the future.
[0097] These data are the result of preprocessing and feature engineering, which effectively shows the relationship between power load and various influencing factors. During the training process, the training data is input into the model and the model parameters are adjusted to improve the prediction effect.
[0098] The model is trained using the training data (x_train and y_train), and the number of training rounds (epochs) is set to 3. The batch size (batch_size) is not directly set, and the batch size is optimized during the optimization process. The validation data (x_val and y_val) are used as validation data to observe the performance of the model on unknown data and the performance during the training process. The validation feature x_val is a multidimensional array, similar to x_train, in which each sample contains a time series data that includes power load and other related factors. The label y_val is a one-dimensional array, similar to y_train, in which each element represents the future power load value of the corresponding time series data. These data are also preprocessed and feature engineered, effectively showing the relationship between power load and various influencing factors.
[0099] Model performance evaluation indicators: In the power forecasting problem, model performance evaluation indicators are used to quantify the prediction ability of the model, thereby guiding the optimization process of the model. Selecting appropriate performance indicators is crucial to evaluating the prediction effect of the model. Various performance indicators show the advantages and disadvantages of the model from different perspectives, helping to fully understand the actual prediction ability of the model. This embodiment uses four key performance indicators, including R2, MAE, RMSE, and MAPE, to evaluate the performance of the power load forecasting model based on CNN-BiLSTM.
[0100] This example analyzes the importance and influencing factors of power demand forecasting, and proposes solutions to address the limitations of traditional forecasting methods. The data preprocessing process is detailed, including collecting and collating historical data and standardizing it. The core idea of model design is explained, that is, integrating convolutional neural networks (CNN) and bidirectional long short-term memory networks (BiLSTM) to capture the time series patterns and characteristics in power demand data. The model training and evaluation process is introduced, and parameter adjustment and key performance indicator evaluation are used to improve the model prediction accuracy and generalization ability.
[0101] Further improvements and optimizations are made in the selection of model parameters and hyperparameters to improve the accuracy and stability of prediction. Therefore, this embodiment will focus on the performance of the CNN-BiLSTM model optimized based on the WOA algorithm in the power load forecasting task.
[0102] Whale Optimization Algorithm (WOA) is a global optimization method based on the predation behavior of whales in nature. This method is characterized by its simple mechanism, fewer parameters and powerful optimization ability. It has been widely used in fields such as economic scheduling, optimal control, photovoltaic systems and image segmentation. Figure 2The following briefly introduces the principle. In power load forecasting, the WOA algorithm can be used to optimize the hyperparameters of the neural network model, such as learning rate, batch size, etc., to improve the prediction accuracy of the model. Specifically, the WOA algorithm searches for the optimal solution in the hyperparameter space to minimize the loss function value of the model on the training set. With this optimization method, the WOA algorithm helps to find the appropriate hyperparameter combination, thereby improving the performance of the neural network model in the power load forecasting task.
[0103] The main advantages of the WOA algorithm are its efficient search of the solution space and global convergence capabilities. Compared with other optimization algorithms, the WOA algorithm is more robust in seeking the global optimal solution and has a relatively low dependence on the initial parameter values. Therefore, in many practical application scenarios, such as power load forecasting and machine learning model optimization, the WOA algorithm has demonstrated excellent performance. In subsequent chapters, we will explore how the WOA algorithm can be combined with the CNN-BiLSTM model to optimize the model parameters and hyperparameters in the power load forecasting task.
[0104] WOA combined with CNN-BiLSTM model:
[0105] Optimization objectives and methods: This embodiment uses the whale optimization algorithm (WOA) to optimize the convolutional neural network-bidirectional long short-term memory (CNN-BiLSTM) model to improve the performance of the power load forecasting task. By finding appropriate hyperparameter values, the WOA algorithm can improve the model prediction accuracy.
[0106] This embodiment mainly optimizes the following two hyperparameters:
[0107] Learning Rate: The learning rate is a key parameter in the neural network training process, which determines the step size of the gradient descent during the weight update process. It is very important to choose an appropriate learning rate, because a learning rate that is too small may cause the model to converge slowly, while a learning rate that is too large may prevent the model from converging. This embodiment uses the WOA algorithm to find a suitable learning rate within a predetermined search range, thereby ensuring that the model performs optimally in terms of stability and convergence speed.
[0108] Batch Size: Batch size is the number of samples used in the weight update process. Choosing an appropriate batch size is critical to the training speed and performance of the model. A smaller batch size can increase the randomness of the training process and help the model escape from the local optimal solution, while a larger batch size can improve computational efficiency. This embodiment uses the WOA algorithm to find a batch size that strikes a balance between training speed and model performance within a predetermined search range.
[0109] To achieve the model optimization goal, the WOA algorithm is applied to the CNN-BiLSTM model to minimize the prediction error of the model on the training set. The WOA algorithm helps to find a suitable hyperparameter combination by globally searching for the optimal solution, thereby improving the performance of the CNN-BiLSTM model in the power load forecasting task. Using this optimization method, this embodiment expects to achieve better practical application effects in the field of power load forecasting, such as accurately predicting power demand in different time periods, assisting power grid operators in rationally dispatching resources and reducing operating costs.
[0110] Hyperparameter search range setting: In the power load forecasting task of this embodiment, in order to enable the WOA algorithm to find appropriate hyperparameter values, an appropriate hyperparameter search range is set. Specifically, the search ranges for learning rate and batch size have been set. The following are the search range settings for these hyperparameters:
[0111] Learning Rate: As a core parameter of neural network training, learning rate affects the weight update process. In this study, the search range of learning rate is 0.001 (1e-3) to 0.01 (1e-2), covering the commonly used learning rate values, thus providing a larger search space for the WOA algorithm to find a suitable learning rate to cope with the complexity of the power load forecasting problem.
[0112] Batch Size: Batch size is the number of samples used for each weight update and has a significant impact on the training speed and performance of the model. In this study, the search range of batch size is set to 32 to 64. This range covers batch size values that can achieve a balance between computational efficiency and model performance in order to achieve good performance in solving the power load forecasting problem.
[0113] By setting an appropriate hyperparameter search range, it is expected that the WOA algorithm can find appropriate hyperparameter values within these ranges, thereby improving the performance of the CNN-BiLSTM model in power load forecasting tasks. It is worth noting that the setting of the search range has an important impact on the optimization results, so in practical applications, it needs to be adjusted according to specific tasks in order to better adapt to different scenarios and needs of the power system.
[0114] The steps of the WOA algorithm code flow chart are as follows Figure 3 , the following is the symbolic description of the WOA algorithm flowchart:
[0115] Among them, parameter a: controls the degree of narrowing of the search range, helping the algorithm gradually shift from global exploration to local search. As the number of iterations increases, the value of a gradually decreases. Parameter p: a randomly generated parameter used to determine which predation strategy the whale adopts. It is used in the code to select different ways to update the whale's position. Coefficient vector A: a linearly decreasing vector used to calculate the new position of the whale. According to the absolute value of A, the algorithm chooses to update the whale's position by surrounding the prey or performing a global random search. Coefficient vector C: used to calculate the new position of the whale in each dimension. It guides other whales to search based on the position of the current optimal whale.
[0116] Fusion: This embodiment combines the WOA algorithm with the CNN-BiLSTM model to optimize the learning rate and batch size to solve the problem of ultra-short-term load forecasting in power systems. For ultra-short-term load forecasting, uncertainty and nonlinear feature processing in power systems, and adapting to dynamically changing power systems, the WOA algorithm improves the performance of the prediction model by optimizing hyperparameters. At the same time, this embodiment also uses the create_cnn_bilstm function to build a CNN-BiLSTM neural network. It is mentioned in Chapter 3 that the network contains multiple convolutional layers, pooling layers, and bidirectional LSTM layers, which helps to extract spatiotemporal features and achieve accurate predictions. In this function, the learning rate (lr) and batch size (batch_size) are used as hyperparameters. Next, the WOA algorithm is used to optimize these two hyperparameters. First, use the Get_CS function to import the WOA algorithm from the Optim.py file and set the parameter search range. Input of the WOA algorithm: training set data (x_train, y_train), validation set data (x_val, y_val), learning rate (lr) and batch size (batch_size) search range (lb, ub). Then, run the WOA algorithm to obtain the optimal learning rate and batch size. The function accepts hyperparameters as input and returns the loss value on the validation set, as shown in the following steps:
[0117] Step 1: Define the objective function: Define the obj_fun function and calculate the loss value of the CNN-BiLSTM model on the validation set under given parameters as the fitness value.
[0118] Step 2: Set parameter range and optimization parameters: Define the parameter range of learning rate (lr) and batch size (batch_size), for example: the learning rate range is 1e-3 to 1e-2, and the batch size range is 32 to 64. Set the population size (n) and the maximum number of iterations (t).
[0119] Step 3: Initialize the Whale Optimization Algorithm: Initialize the Whale Optimization Algorithm (WOA) using the objective function, parameter range, population size, maximum number of iterations, and training and validation data.
[0120] Step 4: Execute the optimization process: Use the WOA algorithm to perform the parameter optimization process, iteratively update the position of the candidate solution (whale), and adjust it according to the fitness value.
[0121] Step 5: Return results: Return the best parameters and fitness values obtained during the optimization process as the optimal combination of the CNN-BiLSTM model; return the tracking record of the WOA algorithm, recording the position and fitness value of the candidate solution in each iteration; return the detailed process of the WOA algorithm, providing information such as the behavior and convergence of the optimization algorithm.
[0122] Where params is a tuple (lr, batch_size), where lr is the learning rate, batch_size is the size of the data set processed in each batch, and represents the hyperparameters required by the model. x_train is the training data input to the model, y_train is the label of the training data input to the model, x_val is the validation data input to the model, y_val is the label of the validation data input to the model, and create_cnn_bilstm is a function used to create the model architecture.
[0123] Next, the WOA algorithm is used to optimize the objective function. In the parameters passed into the WOA algorithm, lb and ub are used to represent the lower and upper bounds of the learning rate and batch size, n represents the number of whales, and t represents the number of iterations.
[0124] In the Optim.py file, a class named WhaleOptimizationAlgorithm is defined to implement the WOA algorithm, which is applied to the problem of ultra-short-term load forecasting of electric power to optimize the hyperparameters of the CNN-BiLSTM model. The main method of this class is run(), which is responsible for executing the iterative process of the WOA algorithm, including updating the position of the whale, calculating the fitness value, selecting the optimal whale, etc. Through the run() method, the optimal learning rate and batch size can be found and output, thereby improving the prediction performance of the neural network.
[0125] Input and output of the WOA algorithm:
[0126] Input: The input of the WOA algorithm includes the objective function (obj_fun), the lower bound (lb) and upper bound (ub) of the search space, the number of whale groups (n), the maximum number of iterations (t), the training set data (x_train, y_train), the validation set data (x_val, y_val), and the function for creating the CNN-BiLSTM model (create_cnn_bilstm)
[0127] The WOA algorithm initialization parameters include: obj_fun: objective function, measuring model performance; lb and ub: lower and upper bounds of the search space; n: number of whale groups; t: maximum number of iterations; x_train, y_train, x_val, y_val: training set and validation set data; create_cnn_bilstm: function to create a CNN-BiLSTM model. The following is a description of the parameters:
[0128] obj_fun is the objective function of the optimization problem. It accepts an n-dimensional vector composed of min and max and returns a real scalar to evaluate the quality of this vector. lb is the lower bound of the optimization variable. It is an array of length n, where n is the dimension of the variable. ub is the upper bound of the optimization variable. It is an array of length n, where n is the dimension of the variable. n is the population size, that is, the number of individuals generated in each generation. t is the maximum number of iterations. x_train is the input data of the training set, y_train is the label data of the training set, x_val is the input data of the validation set, y_val is the label data of the validation set, and create_cnn_bilstm is a function for creating a CNN-BiLSTM model. In addition, the constructor also creates some instance variables: dim is the dimension of the optimization problem, that is, the number of variables. trace is used to save the tracking history during the optimization process. process is used to save the best fitness value and average fitness value of each generation.
[0129] The main implementation logic of the WOA algorithm is in the run method of the class: a group of whales is randomly generated in the search space. Then, the fitness of each whale is evaluated using the objective function (model validation loss).
[0130] In each iteration, the whale with the best fitness is first found. Then, the whale position is updated according to the WOA algorithm principle. This step involves calculating some parameters such as A, C, p, b, and l. Based on these parameter values, it can be determined whether the whale moves closer to the best whale or to other whales. In the process of updating the whale position, it is also necessary to check whether the whale has crossed the boundary of the search space. If so, it needs to be reset to the search space.
[0131] When all iterations are completed, the whale with the best fitness and its corresponding fitness value are returned. These values will be used to determine the optimal hyperparameters of the CNN-BiLSTM model in the power load forecasting task. The calculation formula is shown in Table 1:
[0132] Table 1 Parameter calculation formula
[0133] variable Variable Name formula A a 2a×rand()-a C c 2c×rand()-c D l rand(), needs to be between [-1,1] D p Randomly select an individual X - <![CDATA[x=x best -a×∣C∣×tan(F s ×2π)]]> X - <![CDATA[x=x p -a×∣C∣×sin(Fs×2π)]]>
[0134] The following is a table of specific processes in the application formula. Table 2 below implements a simple form of whale optimization algorithm strategy:
[0135] Table 2 Whale optimization algorithm strategy
[0136] WOA Algorithm Steps describe initialization Randomly initialize the positions and velocities of the whale group members. Objective function calculation Calculate the objective function value for each whale group member Optimal individual and whale group position update Find the current best individual and update the positions of all whale group members. Searcher Location Updates For each whale group member, its position is updated through the formula. Boundary restrictions If the updated position exceeds the boundary, boundary restriction processing is required. Fitness value update and optimal individual update According to the updated position, calculate the fitness value and update the optimal individual Stop condition satisfied When the preset stopping condition is reached, the algorithm stops. If the stop condition is not met, return to step 2 If the stopping condition is not met, return to the second step and recalculate the value of the objective function.
[0137] The following is the specific introduction process:
[0138] (1) Initialize the group: First, you need to initialize a D×N matrix, where D is the dimension of the problem and N is the size of the whale group. This matrix stores the positions of N whale groups.
[0139] (2) Calculation of objective function: For each whale group position x, its fitness value f(x) needs to be calculated. This is obtained by inserting x into the prediction model for calculation.
[0140] (3) Determine the optimal individual and the optimal solution in the group: Among all the whale group positions, it is necessary to find the optimal fitness value f_best and its corresponding optimal position x_best. At the same time, it is also necessary to determine the optimal individual set Pbest of size N / 2 in the current group, in which the optimal solution and its corresponding fitness value are stored.
[0141] (4) Whale group position update: For each whale group position x, it is necessary to update the position by using the formula x_new = x_best + A·D(x_best-x), where x_new is the updated position, A is the regression coefficient, D is the random vector, and x_best is the optimal position in the current group.
[0142] (5) Searcher position update: For all whale group positions that do not belong to the optimal individual set Pbest, the position needs to be updated using the formula x_new = x_rand + A·D(x_rand-x), where x_rand is the random position, A is the regression coefficient, and D is the random vector.
[0143] (6) Boundary restriction: Before updating the position, it is necessary to impose boundary restrictions on the position to ensure that the position is within the range acceptable to the prediction model.
[0144] (7) Update of fitness value and update of optimal individual: For all updated positions x_new, its fitness value f(x_new) needs to be recalculated. At the same time, the optimal individual set Pbest needs to be updated, and the optimal solution x_best and its corresponding fitness value f_best need to be updated.
[0145] (8) Stop condition check: Steps 3 to 7 need to be repeated in a loop until the preset stop condition is met, such as reaching the maximum number of iterations or the adaptability value converges to a certain degree.
[0146] In the Get_CS() function, the objective function obj_fun() is defined, which accepts the model's hyperparameters params (learning rate and batch size) and returns the model's loss value on the validation set. After creating the woa object, the WOA algorithm is started by calling the woa.run() method and returns the optimized hyperparameters. The WOA algorithm attempts to minimize this objective function to find the optimal hyperparameters of the CNN-BiLSTM model in the power load forecasting task. The Get_CS() function uses the WhaleOptimizationAlgorithm class to execute the WOA algorithm and returns the best hyperparameters as well as the best fitness value and average fitness value during the iteration. The following is the Get_CS() function step flow:
[0147] Step 1: Define a function named Get_CS with parameters x_train, y_train, x_val, y_val and create_cnn_bilstm.
[0148] Step 2: Define the internal parameter optimization function obj_fun. The parameters of this function include params, x_train, y_train, x_val, y_val and create_cnn_bilstm, and return the loss value of the model on the validation set.
[0149] Step 3: Define the upper and lower bounds lb and ub of the optimization parameters, and set n representing the number of parameters and the number of iterations t.
[0150] Step 4: Create the WOA algorithm object. The input parameters include obj_fun, lb, ub, n, t, and the remaining x_train, y_train, x_val, y_val, and create_cnn_bilstm parameters.
[0151] Step 5: Run the WOA algorithm.
[0152] Step 6: Return the optimal parameters best_params, the tracking information woa.trace of the WOA algorithm and the processing result woa.process.
[0153] During the model training process, the results of the WOA algorithm are used to determine the model's learning rate and batch size, thereby optimizing the model performance. The specific steps are as follows:
[0154] Step 1: In the problem of ultra-short-term load forecasting of electric power, the Get_CS() function is used to execute the WOA algorithm to obtain the optimal hyperparameters to improve the forecasting performance.
[0155] Step 2: Use create_cnn_bilstm() function to create a model based on the optimal hyperparameters.
[0156] Step 3: Use model.fit() method to train the model.
[0157] Step 4: Save the trained model to a file.
[0158] Through the WOA algorithm, the optimal learning rate and batch size can be found to improve the performance of the CNN-BiLSTM model in the power load forecasting task. Figure 4 As shown in Figure 1, this is the prediction result after WOA optimization.
[0159] In this section, the prediction result diagram of the CNN-BiLSTM hybrid model after optimization by the WOA algorithm is shown, where the horizontal axis represents the time of the sampling point, the vertical axis represents the power load value, and the blue solid line is used to represent the curve of the real power load data, which can more conveniently show the gap between the model of this embodiment and the real value. Figure 4 It can be seen that the predicted value and the true value are very close.
[0160] This embodiment discusses in detail the performance of various models in the power load forecasting task, including the CNN-BiLSTM model optimized by the WOA algorithm, the CNN-BiLSTM model, the BP neural network and the BiLSTM model. Four evaluation indicators are used: R2 score, mean absolute error (MAE), root mean square error (RMSE) and mean percentage error (MAPE) for detailed comparison and analysis. Table 3 below shows the evaluation indicator results of each model:
[0161] Table 3 Evaluation index results of each model
[0162]
[0163] According to the above results, the CNN-BiLSTM model optimized by the WOA algorithm achieved the best performance in all four evaluation indicators. 2 The score is as high as 0.9786, showing a high degree of fit and accurately capturing the changing trend of power load. In addition, the MAE, RMSE and MAPE of the model are 174.60, 217.88 and 2.459% respectively, indicating that its prediction error is small and has high prediction accuracy.
[0164] Figure 5 It is a comparison of the prediction graphs of various models. The figure shows five curves, which include the true values and the comparison between the models. The comparison effect can be intuitively felt. From the data in the figure, we can intuitively feel that the CNN-BiLSTM model and the CNN-BiLSTM model optimized by the WOA algorithm perform very well in the power load forecasting task, while the performance of other single models is poor.
[0165] This embodiment focuses on the application of the whale optimization algorithm (WOA) in optimizing the convolutional neural network-bidirectional long short-term memory network (CNN-BiLSTM) model, aiming to improve the performance of the power load forecasting task. The principle of the WOA algorithm and the application method of optimizing the learning rate and batch size are introduced in detail. In the experiment, the prediction performance of the CNN-BiLSTM model optimized by WOA, the original CNN-BiLSTM model, the BP neural network and the BiLSTM model were compared. By comparing the prediction accuracy of each model horizontally, the results show that the CNN-BiLSTM model optimized by WOA has the best fit and prediction accuracy, and the performance of other models is relatively poor.
[0166] The experimental results of this embodiment fully verify the effectiveness of the WOA algorithm in optimizing the CNN-BiLSTM model. In real-world data rather than academic simulation data, the CNN-BiLSTM model optimized by WOA achieves a high level of prediction, providing more accurate load forecasting for the power industry.
[0167] A method for predicting electric load based on a neural network, comprising:
[0168] A data acquisition module is used to obtain historical data of the power system, wherein the historical data includes power load values and power load influencing factor data at different time points in the power system;
[0169] A parameter optimization module is used to construct a power load prediction model, wherein the power load prediction model includes a convolutional layer, a pooling layer, a bidirectional LSTM layer and a fully connected layer connected in sequence; extract the hyperparameters included in the power load prediction model, train the power load prediction model based on historical data, and use the loss of the training result as the fitness value corresponding to each hyperparameter; perform parameter optimization on each hyperparameter based on the fitness value corresponding to each hyperparameter in combination with a whale optimization algorithm to obtain the optimal hyperparameter; apply the optimal hyperparameter to the power load prediction model to obtain the power load prediction model after parameter optimization;
[0170] The power load forecasting is used to perform the power load forecasting of the power system according to the power load forecasting model after parameter optimization to obtain the power load forecasting result.
[0171] An electronic device includes a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the neural network-based power load forecasting method.
[0172] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements a neural network-based power load forecasting method.
[0173] The above is only a preferred specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for predicting power load based on neural network, characterized in that: include: Acquire historical data of the power system, wherein the historical data includes power load values and power load influencing factor data at different time points in the power system; Constructing a power load forecasting model, wherein the power load forecasting model includes a convolutional layer, a pooling layer, a bidirectional LSTM layer, and a fully connected layer connected in sequence; Extracting hyperparameters included in the power load forecasting model, training the power load forecasting model based on historical data, and using the loss of the training result as the fitness value corresponding to each of the hyperparameters; Based on the fitness value corresponding to each hyperparameter and in combination with the whale optimization algorithm, each hyperparameter is optimized to obtain the optimal hyperparameter; Applying the optimal hyperparameters to the power load forecasting model to obtain a power load forecasting model after parameter optimization; The power load prediction of the power system is performed based on the power load prediction model after parameter optimization to obtain a power load prediction result.
2. A method for predicting power load based on neural network according to claim 1, characterized in that: Before training the power load forecasting model based on historical data, it also includes performing missing value processing, outlier processing, normalization and data reconstruction on the historical data to obtain pre-processed historical data, and training the power load forecasting model based on the pre-processed historical data.
3. The method for predicting power load based on neural network according to claim 1, characterized in that: The power load prediction model is trained based on historical data, specifically including: Acquire training data, wherein the training data includes historical data and corresponding prediction labels, wherein the prediction labels are power load prediction values of the historical data after a preset time period; An initial power load forecasting model is constructed, the training data is input into the initial power load forecasting model, local features of the training data and historical data are extracted through the convolution layer to obtain local features, the local features are pooled through the pooling layer, and the pooled local features are input into the bidirectional LSTM layer to extract spatiotemporal features to obtain spatiotemporal features; the local features and the spatiotemporal features are input into the fully connected layer for classification prediction, and training is performed with the goal of minimizing the loss between the initial training result after classification prediction and the prediction label corresponding to the historical data to obtain a trained power load forecasting model.
4. The method for predicting power load based on neural network according to claim 3, characterized in that: The process of obtaining the predicted label specifically includes: The historical data is used as input features, and based on the sliding window method, the input features are combined in the window to perform power load prediction after a preset time period, so as to obtain a power load prediction value after the preset time period, and the power load prediction value after the preset time period is used as a prediction label for the historical data.
5. The method for predicting power load based on neural network according to claim 1, characterized in that: Based on the fitness value corresponding to each hyperparameter combined with the whale optimization algorithm, the hyperparameters are optimized to obtain the optimal hyperparameters, specifically including: An initial population is constructed based on a preset population size, each of the hyperparameters and the corresponding fitness values, and each hyperparameter in the initial population is iteratively updated multiple times based on the whale optimization algorithm. In each iterative update process, the fitness value corresponding to each of the hyperparameters is calculated, and the initial population is updated based on the fitness value corresponding to each of the hyperparameters, until the number of iterations reaches a preset number of iterations, and then the optimal hyperparameters are output.
6. A method for predicting power load based on neural network, characterized in that: include: A data acquisition module is used to obtain historical data of the power system, wherein the historical data includes power load values and power load influencing factor data at different time points in the power system; A parameter optimization module is used to construct a power load prediction model, wherein the power load prediction model includes a convolutional layer, a pooling layer, a bidirectional LSTM layer and a fully connected layer connected in sequence; extract the hyperparameters included in the power load prediction model, train the power load prediction model based on historical data, and use the loss of the training result as the fitness value corresponding to each hyperparameter; perform parameter optimization on each hyperparameter based on the fitness value corresponding to each hyperparameter in combination with a whale optimization algorithm to obtain the optimal hyperparameter; apply the optimal hyperparameter to the power load prediction model to obtain the power load prediction model after parameter optimization; The power load forecasting is used to perform the power load forecasting of the power system according to the power load forecasting model after parameter optimization to obtain the power load forecasting result.
7. An electronic device, characterized in that: It comprises a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute a power load forecasting method based on a neural network according to any one of claims 1-5.
8. A computer-readable storage medium, characterized in that: It stores a computer program, which, when executed by a processor, implements a neural network-based power load forecasting method as described in any one of claims 1-5.
Citation Information
Patent Citations
Regenerative aluminum melting furnace parameter optimization setting method based on improved whale optimization algorithm
CN110030843A
Station terminal load prediction method and prediction device
CN112700060A
Short-term power load prediction method and device based on deep mixed learning model
CN115936208A
Short-term power load prediction method based on TWOA-LSTM
CN118014131A
User electrical load data prediction method and system, terminal and storage medium
CN118017503A
Cited By
Automobile factory energy consumption prediction method and management system
CN121279671A
