A Short-Term Power Load Forecasting Method Based on Hunter-Prey Optimization XGBoost
By optimizing the XGBoost algorithm using hunter-prey optimization and KPCA feature dimensionality reduction, the short-term power load forecasting model is improved, solving the problems of insufficient forecasting speed and accuracy in existing technologies, and realizing efficient operation of the power system and accurate load forecasting.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-17
- Publication Date
- 2026-03-06
AI Technical Summary
Existing short-term power load forecasting methods are not robust enough when dealing with large-scale power data, and it is difficult to balance speed and accuracy, especially in the dynamic balance of power systems.
The hunter-prey optimization XGBoost algorithm is adopted, combined with KPCA for feature dimensionality reduction, and the hyperparameters of the XGBoost model are optimized by the hunter-prey optimization algorithm. Short-term power load forecasting is carried out using historical load data, electricity price data, meteorological data, etc.
It enables rapid and accurate short-term power load forecasting, improves the supply and demand balance of the power system and the utilization rate of power generation equipment, and enhances the robustness and accuracy of the forecasting model.
Smart Images

Figure CN116187582B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of power load forecasting and artificial intelligence, and in particular to a short-term power load forecasting method based on hunter-prey optimization XGBoost. Background Technology
[0002] Against the backdrop of the "dual carbon" goals, electricity market reforms have been further deepened, with new technologies and roles such as demand response, load aggregators, and virtual power plants being continuously introduced. This has led to more complex and dynamic characteristics and forms of electricity load. To ensure a dynamic balance between electricity supply and demand and to guarantee the safe, stable, and efficient operation of the power system, load forecasting plays a crucial role.
[0003] Short-term power load forecasting studies electricity demand over the next few days. Accurate load forecasting not only ensures a balance between power supply and demand but also improves the utilization rate of power generation equipment. The widespread deployment of smart metering devices and improved communication capabilities have made it possible to obtain more detailed and accurate big data on electricity. Based on this, compared to deep learning algorithms, ensemble machine learning algorithms that combine multiple methods are more robust, faster, and more effective at processing large-scale datasets, enabling rapid and accurate short-term power load forecasting. Summary of the Invention
[0004] Based on the above background, the present invention provides a short-term power load forecasting method based on hunter-prey optimization XGBoost.
[0005] To achieve the above objectives, the technical solution adopted by this invention is as follows: a short-term power load forecasting method based on hunter-prey optimization XGBoost, comprising the following steps:
[0006] Step 1: Obtain data on factors affecting load forecasting in the predicted area and load data, preprocess the data, and divide the preprocessed data into training set and prediction set according to a certain ratio;
[0007] Step 2: Use KPCA to perform feature dimensionality reduction and decoupling on the training set data;
[0008] Step 3: Use the training set after feature dimensionality reduction as input to the Hunter-Prey Optimization (HPO) algorithm to optimize the XGBoost model and train it to obtain the prediction model;
[0009] Step 4: Input the prediction set into the prediction model trained by S3 after dimensionality reduction and decoupling, and correct the output value of the prediction model to output the short-term load prediction value.
[0010] Furthermore, in step one, the data on factors affecting load forecasting and load data specifically include historical load data, electricity price data, meteorological data, time periods, weekday types, and day types. The sampling interval for the above data is 1 hour.
[0011] Furthermore, in step one, the specific method for preprocessing the collected data is as follows:
[0012] First, calculate the mean μ(t) and variance σ(t) of the data at time t for each day in the entire dataset, as shown in the following formula:
[0013]
[0014]
[0015] In the formula, x(t,i) represents the data at time t on day i, where i = 1, 2, ..., N;
[0016] The deviation rate z(t,i) for each data point is calculated using the following formula:
[0017]
[0018] Set the outlier detection threshold Z thr If z(t,i)≥Z, then the value is 2.5. thr If the data point is an outlier, it is considered a normal value; otherwise, it is considered a normal value.
[0019] To ensure the randomness of the data, outliers are cleared to zero and listed as missing values. The predicted average matching method is then used to fill in the missing values.
[0020] Furthermore, in step one, the preprocessed dataset is divided into a training set and a prediction set in a 12:1 ratio.
[0021] Furthermore, in step two, KPCA is used to perform feature dimensionality reduction and decoupling on the training set data. The specific method is as follows:
[0022] The preprocessed test data from step one forms a sample set X∈R. P×M M is the number of samples, and P is the number of variables in each sample;
[0023] Choosing the Sigmoid kernel function, the sum matrix is centered to establish a standard kernel matrix. The formula is as follows:
[0024]
[0025] In the formula, I 1 / M It is an M×M matrix with the same dimension as the kernel matrix, and all its elements are 1 / M;
[0026] For matrix Perform PCA to find the eigenvalues λ1, λ2, ..., λ P and eigenvectors P1, P2, ..., P P ;
[0027] For matrix Perform PCA to find the eigenvalues λ1, λ2, ..., λ P and eigenvectors P1, P2, ..., P P ;
[0028] The largest d features (d << P) are obtained, and their corresponding principal component components are α1, α2, ..., α d The dimensionality-reduced data can be obtained.
[0029] Furthermore, in step three, XGBoost is used to predict the load, and the hunter-prey optimization algorithm is used to optimize the five hyperparameters of XGBoost to train the prediction model. The specific method is as follows:
[0030] Initialize parameters, set the population size n pop Maximum number of iterations The generation and adjustment parameter δ, where δ is any value between 0 and 1, are used to randomly generate the position of each member i in the initial population in the search space, as shown in the following formula:
[0031] x i = rand(1, dim).*(u bound -l bound )+l bound
[0032] In the formula, x i Indicates the location of the hunter or prey, x i =[l rate ,γ XGB ,dep max ,mcw,λ XGB [x] represents the learning rate of XGBoost, the minimum loss function decrease required for node splitting, the maximum depth of the tree, the minimum leaf node sample weight, and the weight of the regularization term, respectively, dim = 5, u bound =[0.3,0.2,10,10,10] and l bound = [0,0,4,1,0.1] represent the upper and lower bounds of the hyperparameters to be optimized, respectively;
[0033] Determine the fitness function, and take the mean squared error of the prediction model as the evaluation function, as shown in the following formula:
[0034]
[0035] In the formula, fiti Let y be the fitness of the i-th solution, n be the number of solutions, and y be the fitness of the i-th solution. i This is the actual value. For the predicted value, when fit i The optimal solution is obtained when the minimum value is reached;
[0036] By adjusting the fitness function fit i The results are sorted, and the minimum mean squared error is calculated using minfit. i Its corresponding position is the optimal position. Let the current iteration number be... Introducing a balance parameter C and an adaptive parameter Z, with the value of C decreasing from 1 to 0.02 during the iteration process, as shown in the following formula:
[0037]
[0038] P=rand(1)<C; IDX=(P==0);
[0039] If rand(1) < δ, the current x i The hunter, acting as a predator, moves toward the prey, searching for stray animals, and includes the following steps:
[0040] (1) Calculate the average position of individuals within the population
[0041] (2) Calculate the Euclidean distance of all individuals to the mean position μ and sort them to obtain Dist. Select the individual x with the farthest distance. j As prey P pos And P pos =Dist(K best ), where K best =round(C*n pop Therefore, the hunter updates the location using the following formula:
[0042] x i (t+1)=x i (t)+0.5[(2C·Z·P pos -x i (t))+(2(1-C)Z·μ-x i (t))]
[0043] If rand(1)≥δ, the current x i Once considered prey, prey dynamically adjusts its position, tending towards safer areas. Therefore, the formula for prey relocating is as follows:
[0044] x i (t+1)=x best +C·Zcos(2πR r)×(x best -x i (t)),
[0045] In the formula R r A random number in the range [-1, 1];
[0046] If fit i (x new ) is better than fit i (x best If x is updated, then x is updated. best Then iterates continuously until the maximum number of iterations is reached, and the optimal XGBoost hyperparameters are output.
[0047] Replace the original XGBoost parameters with the hyperparameters output in the previous step, and train the optimized XGBoost model using the training set data.
[0048] Furthermore, in step four, the model's prediction results are obtained and corrected. The specific method is as follows:
[0049] The average of the results from 20 consecutive predictions of the model is taken.
[0050] Compare the 20 output values with the mean. If the error between the output value and the mean is greater than 10%, the value with large fluctuations is removed.
[0051] The average of the remaining output values is used as the final model output value, i.e., the short-term load forecast value. Attached Figure Description
[0052] Appendix Figure 1 This is a flowchart of short-term power load forecasting;
[0053] Appendix Figure 2 This is the flowchart of the HPO algorithm for optimizing XGBoost hyperparameters. Detailed Implementation
[0054] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0055] This invention discloses a short-term power load forecasting method based on hunter-prey optimization XGBoost, such as... Figure 1 ,include:
[0056] S1. Obtain data on factors affecting load prediction in the predicted area and load data, preprocess the data, and divide the preprocessed data into training set and prediction set according to a certain proportion;
[0057] S2. Use KPCA to perform feature dimensionality reduction and decoupling on the training set data;
[0058] S3. Use the training set after feature dimensionality reduction as input to the hunter-prey optimization XGBoost model and train it to obtain the prediction model.
[0059] S4. After dimensionality reduction and decoupling, the prediction set is input into the prediction model trained in S3, and the output value of the prediction model is corrected to output the short-term load prediction value.
[0060] Preferably, in step S1, the data on factors affecting load forecasting and load data specifically include historical load data, electricity price data, meteorological data, time period, week type, and day type, with a sampling interval of 1 hour for the above data.
[0061] Preferably, in step S1, the collected data is preprocessed, including the following steps:
[0062] First, calculate the mean μ(t) and variance σ(t) of the data at time t for each day in the entire dataset, as shown in the following formula:
[0063]
[0064]
[0065] In the formula, x(t,i) represents the data at time t on day i, where i = 1, 2, ..., N;
[0066] The deviation rate z(t,i) for each data point is calculated using the following formula:
[0067]
[0068] Set the outlier detection threshold Z thr If z(t,i)≥Z, then the value is 2.5. thr If the data point is an outlier, it is considered a normal value; otherwise, it is considered a normal value.
[0069] To ensure the randomness of the data, outliers are cleared to zero and listed as missing values. The predicted average matching method is then used to fill in the missing values.
[0070] Preferably, in step S1, the preprocessed dataset is divided into a training set and a prediction set in a 12:1 ratio.
[0071] Preferably, in step S2, KPCA is used to perform feature dimensionality reduction and decoupling on the training set data, including the following steps:
[0072] The preprocessed test data from step S1 forms a sample set X∈R P×M M is the number of samples, and P is the number of variables in each sample;
[0073] Choosing the Sigmoid kernel function, the sum matrix is centered to establish a standard kernel matrix. The formula is as follows:
[0074]
[0075] In the formula, I 1 / M It is an M×M matrix with the same dimension as the kernel matrix, and all its elements are 1 / M;
[0076] For matrix Perform PCA to find the eigenvalues λ1, λ2, ..., λ P and eigenvectors P1, P2, ..., P P ;
[0077] For matrix Perform PCA to find the eigenvalues λ1, λ2, ..., λ P and eigenvectors P1, P2, ..., P P ;
[0078] The largest d features (d << P) are obtained, and their corresponding principal component components are α1, α2, ..., α d The dimensionality-reduced data can be obtained.
[0079] Preferably, in step S3, XGBoost is used to predict the load, and the hunter-prey optimization algorithm is used to optimize the five hyperparameters of XGBoost to train a prediction model, including the following steps:
[0080] Initialize parameters, set the population size n pop Maximum number of iterations The generation and adjustment parameter δ, where δ is any value between 0 and 1, are used to randomly generate the position of each member i in the initial population in the search space, as shown in the following formula:
[0081] x i = rand(1, dim).*(u bound -l bound )+l bound
[0082] In the formula, x i Indicates the location of the hunter or prey, x i =[lrate ,γ XGB ,dep max ,mcw,λ XGB [x] represents the learning rate of XGBoost, the minimum loss function decrease required for node splitting, the maximum depth of the tree, the minimum leaf node sample weight, and the weight of the regularization term, respectively, dim = 5, u bound =[0.3,0.2,10,10,10] and l bound = [0,0,4,1,0.1] represent the upper and lower bounds of the hyperparameters to be optimized, respectively;
[0083] Determine the fitness function, and take the mean squared error of the prediction model as the evaluation function, as shown in the following formula:
[0084]
[0085] In the formula, fit i Let y be the fitness of the i-th solution, n be the number of solutions, and y be the fitness of the i-th solution. i This is the actual value. For the predicted value, when fit i The optimal solution is obtained when the minimum value is reached;
[0086] By adjusting the fitness function fit i The results are sorted, and the minimum mean squared error is calculated using minfit. i Its corresponding position is the optimal position. Let the current iteration number be... Introducing a balance parameter C and an adaptive parameter Z, with the value of C decreasing from 1 to 0.02 during the iteration process, as shown in the following formula:
[0087]
[0088] P=rand(1)<C; IDX=(P==0);
[0089] If rand(1) < δ, the current x i The hunter, acting as a predator, moves toward the prey, searching for stray animals, and includes the following steps:
[0090] (1) Calculate the average position of individuals within the population
[0091] (2) Calculate the Euclidean distance of all individuals to the mean position μ and sort them to obtain Dist. Select the individual x with the farthest distance. j As prey P pos And P pos =Dist(K best ), where K best =round(C*npop Therefore, the hunter updates the location using the following formula:
[0092] x i (t+1)=x i (t)+0.5[(2C·Z·P pos -x i (t))+(2(1-C)Z·μ-x i (t))]
[0093] If rand(1)≥δ, the current x i Once considered prey, prey dynamically adjusts its position, tending towards safer areas. Therefore, the formula for prey relocating is as follows:
[0094] x i (t+1)=x best +C·Zcos(2πR r )×(x best -x i (t)),
[0095] In the formula R r A random number in the range [-1, 1];
[0096] If fit i (x new ) is better than fit i (x best If x is updated, then x is updated. best Then iterates continuously until the maximum number of iterations is reached, and the optimal XGBoost hyperparameters are output.
[0097] The optimal hyperparameters are input into the XGBoost model, and the optimized XGBoost model is trained using the training set data.
[0098] Preferably, in step S4, the prediction results of the model are obtained and the prediction results are corrected, including the following steps:
[0099] The average of the results from 20 consecutive predictions of the model is taken.
[0100] Compare the 20 output values with the mean. If the error between the output value and the mean is greater than 10%, the value with large fluctuations is removed.
[0101] The average of the remaining output values is used as the final model output value, i.e., the short-term load forecast value.
Claims
1. A short-term electric power load forecasting method based on hunter-prey optimization XGBoost, characterized in that, The method comprises the following steps: S1, acquiring data of factors affecting load prediction in a predicted area and load data, pre-processing the data, and dividing the pre-processed data into a training set and a prediction set according to a certain proportion sequence; S2, using KPCA to decouple the feature dimensionality reduction of the training set data; S3, taking the training set after feature dimensionality reduction as the input of a Hunter-Prey Optimization (HPO) optimized XGBoost model and training the input to obtain a prediction model; S4, inputting the prediction set after dimensionality reduction decoupling into the prediction model trained in S3, correcting the output value of the prediction model, and outputting a short-term load prediction value; In S3, XGBoost is used to predict the load, and the Hunter-Prey Optimization algorithm is used to optimize the five hyperparameters of XGBoost to train the prediction model, comprising the following steps: S31. Initialize parameters, set population size. Maximum number of iterations Substitution and adjustment parameters ,and For any value between 0 and 1, each member of the initial population is randomly generated in the search space. The position is given by the following formula: wherein represents the position of the hunter or the prey, are the learning rate, the minimum loss function decrease required for node splitting, the maximum depth of the tree, the minimum leaf node sample weight, and the weight of the regularization term for XGBoost, respectively, , and represent the upper and lower bounds of the hyperparameters to be optimized, respectively; S32, determining a fitness function, taking the mean square error of the prediction model as the evaluation function, and the formula is as follows: wherein, is the fitness of the th solution, is the number of solutions, is the actual value, is the predicted value, and when reaches a minimum value, the optimal solution is obtained. S33、through the fitness function The results are sorted to get the minimum mean square error , which corresponds to the optimal position , set the current iteration number , the balance parameter C and adaptive parameter Z are introduced, and the value of C decreases from 1 to 0.02 in the iteration process, as follows: ; S34、if , current is considered a hunter, the hunter moves towards the prey to find the outlier prey, comprising the steps of: S341. Calculate the average position of individuals within the population ; S342, compute all individuals to average position euclidean distance sort gets select the farthest individual as prey and where so the hunter updates position, formula in next: ; S35、If , current is considered prey, prey is also dynamically adjusted position, tend to be safer zone, so prey update location, as follows: , wherein is a random number in the range [-1, 1]; S36、if Better than Then update Then iterate constantly until the maximum number of iterations is reached, and the optimal XGBoost hyperparameters are output; S37, replacing the original parameters of XGBoost with the output of S36, and training the optimized XGBoost model using the training set data.
2. The method of claim 1, wherein the method is based on XGBoost optimized for short-term power load forecasting. In S1, the data of factors affecting load prediction and load data specifically include historical load data, electricity price data, weather data, time period, week type, and day type, and the sampling time interval of the above data is 1 hour.
3. The method of claim 1, wherein the method is based on XGBoost optimized for short-term power load forecasting. In S1, the collected data is pre-processed, comprising the following steps: S11, compute and , as follows: wherein is the average value of the data at time t for the entire data set, is the variance of the data at time t for each day, represents the data at time t for the day, ; S12, calculate the deviation rate of each data point The formula is as follows: ; S13, set an outlier decision threshold is 2.5, if then the data point is determined to be an outlier, otherwise it is a normal value; S14, to ensure the randomness of the data, the abnormal values are set to zero and included as missing values, and the predicted average value matching method is used to complete the missing values.
4. The method of claim 1, wherein, In S1, the pre-processed data set is divided into a training set and a prediction set in the order of 12:
1.
5. The method of claim 1, wherein, In S2, the following steps are included: S21, forming a sample set with the preprocessed test data M is the number of samples, and P is the number of variables contained in each sample. S22, select Sigmoid kernel function, make centering processing to and matrix, establish standard kernel matrix The formula is as follows: In the formula, is a matrix of the same dimension as the kernel matrix, all elements of which are ; S23, to matrix Do PCA, find eigenvalues and eigenvectors ; S24, to the feature vector orthogonal unitization is performed to obtain the kernel principal component components ; S25, obtain the maximum one feature whose corresponding principal component is obtain the reduced dimension data , .
6. The method of claim 1, wherein, In S4, the prediction result of the model is obtained, and the prediction result is corrected, comprising the following steps: S41, taking the average of the results of the prediction model for 20 times; S42, comparing the output value with the average value, if the error between the output value and the average value is greater than 10%, the value with large fluctuation is removed; S43, taking the average of the remaining output values as the final model output value, that is, the short-term load prediction value.