Short-term power system inertia prediction method based on shap-xgboost algorithm
An interpretable short-term power system inertia prediction model was constructed using the SHAP-XGBoost algorithm. This model addresses the issues of insufficient accuracy and interpretability in inertia prediction after the integration of new energy sources into the grid, achieving high-precision and interpretable power system inertia prediction and supporting the safe and stable operation of the power grid.
Patent Information
- Application Number
- CN202211412496.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-11
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2042-11-11
AI Technical Summary
Existing short-term prediction methods for power system inertia cannot simultaneously guarantee high accuracy and interpretability after new energy sources are connected to the grid, posing challenges to the safe and stable operation of the power system.
A short-term prediction method for power system inertia based on the SHAP-XGBoost algorithm is adopted. By constructing an interpretable XGBoost model, the importance of each feature is explained by the SHAP value. Combined with the spatiotemporal variation mechanism of power system frequency, data preprocessing and feature selection are performed to construct a short-term inertia prediction framework for power system, realizing deep learning and interpretable analysis of the model.
It improves the accuracy and reliability of short-term prediction of power system inertia, can interpret key physical quantities globally and interpret each prediction result locally, and helps power grid dispatching departments to formulate control measures to improve system security and economic dispatch.
Smart Images

Figure CN115759380B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power system operation analysis, and specifically to a short-term prediction method for power system inertia based on the SHAP-XGBoost algorithm. Background Technology
[0002] With the depletion of traditional fossil fuels and the increasing prominence of environmental problems, new energy sources are rapidly developing. The integration of numerous new energy sources with power electronic equipment into the grid is causing a decrease in power system inertia, resulting in significant frequency issues and threatening the safe and stable operation of the power system. Power system inertia, a crucial parameter in the power system, is determined by the rotating mass of synchronous generators and turbines. When power generation and demand are unbalanced, inertia affects the instantaneous frequency response. Therefore, rapidly and accurately predicting the short-term inertia of the power system and understanding its inertia level in advance to warn of when the system will face the risk of inertia weakness is not only a key variable for ensuring system operation and economic dispatch in highly penetrated new energy power systems, but also an important prerequisite for making optimal operational decisions.
[0003] Currently, research on short-term inertia prediction methods for power systems mainly focuses on statistical methods and machine learning methods. Statistical methods primarily include regression analysis, differential autoregressive moving average models, minimum variance finite impulse response filters, and Bayesian models. Prediction based on statistical methods assumes that system inertia is generated solely by synchronous generators. However, this method lacks representation of other complex nonlinear virtual inertia in modern power systems. Machine learning methods, on the other hand, avoid the analysis of complex grid characteristics and the derivation of high-dimensional nonlinear formulas. Compared to linear models, they often have better accuracy in prediction. However, the prediction process of machine learning models is similar to a "black box," lacking interpretability. The results are difficult to provide relevant interpretive information for specific decision-making by grid dispatching departments, which is the main problem with the current application of machine learning methods in short-term inertia prediction.
[0004] In dealing with large-scale data problems related to short-term prediction of system inertia, XGBoost models struggle to balance complexity and prediction accuracy. Recent research has separated interpretation from machine learning models, with interpretability methods including global surrogate models and local surrogate models. These methods, while maintaining high accuracy, can capture the internal feature correlations of the model and have been applied in fields such as biomedical forecasting, financial forecasting, and computer vision. However, they have rarely been used in power system inertia prediction research. Therefore, to ensure system economy and safety, it is urgent to propose an interpretable XGBoost method for short-term power system inertia prediction, thereby achieving a balance between prediction accuracy and interpretability, and promoting safe system operation and economical dispatch. Summary of the Invention
[0005] To address the shortcomings and deficiencies of existing technologies, this invention provides a short-term prediction method for power system inertia based on the SHAP-XGBoost algorithm. The aim is to fully utilize the interpretability of machine learning models to improve the accuracy of short-term power system inertia prediction. This method offers advantages such as low cost, simplicity and efficiency, complete and accurate data, no need for experiments, and no complex computational processes.
[0006] The technical solution adopted in this invention is as follows:
[0007] A short-term prediction method for power system inertia based on the SHAP-XGBoost algorithm includes the following steps:
[0008] Step 1: Considering the spatiotemporal variation mechanism of power system frequency, determine the input characteristics of power system short-term inertia prediction, and construct a short-term inertia prediction learning model based on XGBoost;
[0009] Step 2: Based on the short-term inertia prediction learning model established in Step 1, considering the impact of the lack of interpretability of traditional machine learning models, an interpretable learning algorithm based on SHAP-XGBoost is proposed to realize the deep learning of the short-term inertia prediction learning model.
[0010] Step 3: Construct a short-term inertia prediction framework for the power system to realize the prediction model for power system inertia.
[0011] In step 1, historical data is first collected based on the Wide Area Measurement and Management System (WAMS), and relevant physical quantities affecting the system's inertia prediction are extracted as input features. Since it's difficult to avoid missing values, outliers, and other noisy data during feature data collection, data preprocessing is necessary before use. This involves data cleaning and imputation of the dataset. Missing values are directly filled using numerical calculations, and outliers are replaced with the mean. This process preserves features while ensuring unbiased estimation. After a series of processing steps, a dataset suitable for training the predictive learning model is finally obtained.
[0012] Wherein: The sample dataset is described as shown in equations (1) to (2), and each row of the input sample set corresponds to the output sample set:
[0013]
[0014] Y = [y1, y2, ..., y n ] T (2);
[0015] In the formula, X is the input sample dataset; Y is the output sample dataset; the superscript m is the dimension of the input feature; and the subscript n is the number of input samples. Each row of X represents an input sample.
[0016] When selecting input features, it is necessary to ensure that they can reflect the system inertia characteristics well, and that the calculation is fast in time. Therefore, in order to ensure the accuracy of power system inertia prediction, appropriate features are selected based on the power system inertia response equation in the dynamic change of active power and frequency, as shown in equation (3).
[0017]
[0018] In equation (3), H sys and D sys These represent the system inertia and system damping, respectively; ΔP is the system power change rate; and Δf is the system power rate. COI It is the frequency deviation of the inertia center; as shown in equation (3), the factors affecting the system inertia are frequency and the active power of various energy sources. Therefore, the system frequency and load demand should be considered when selecting input characteristics.
[0019] Short-term inertia prediction learning model based on XGBoost:
[0020] XGBoost is an ensemble learning model that uses Boosting and employs CART (Classification and Regression Tree) as its base learner, as shown below:
[0021]
[0022] In the formula: x is the model's predicted value. i For the i-th sample; f k Let be an independent function in the space; F is the function space composed of all CARTs. XGBoost adds a regularization term to the loss function to prevent overfitting, and its objective function is shown below:
[0023]
[0024]
[0025] In equation (5): the first term represents the error between the predicted value and the actual value, and the second term is the regularization term.
[0026] In equation (6): T is the number of leaf nodes; ω j γ represents the weight of the leaf nodes; γ and λ are pre-defined hyperparameters used to control the number and score of leaf nodes, respectively. Since the optimization parameters of the objective function are a tree model, iteratively decomposed into a tree learning process. While keeping the original model unchanged, incremental training is used to minimize the objective function, updating the objective function after each iteration as follows:
[0027]
[0028] The second-order Taylor expansion transforms equation (7) into a function of the independent variable ω. j It takes the form of a quadratic function in one variable.
[0029] make I j Given the sample set of node j, obtain the optimal solution. The corresponding optimal objective function value is:
[0030]
[0031]
[0032] During training, the splitting criterion of the spanning tree model adopts a greedy algorithm, selecting the feature node that maximizes the gain of the objective function before and after the node split as the splitting point, as shown below:
[0033]
[0034] In the formula, G L H L G R H R These are the first and second derivatives of the left and right subtrees of the current node during the split, respectively.
[0035] In step 2, the impact of the uninterpretability of traditional machine learning models is considered. Specifically, machine learning models are divided into white-box models and black-box models. Simple linear models and single decision trees belong to white-box models, and the way they map inputs to outputs can be fully understood. However, random forests composed of many decision trees, boosting trees, and deep neural networks belong to black-box models. The mapping from input to output of these models is very complex, and it is almost impossible to fully understand the internal workings of the machine.
[0036] An interpretable XGBoost model is built based on SHAP. By calculating the Shapley value to globally explain the importance of each feature, the black-box structure can be deconstructed and analyzed from multiple dimensions to analyze the impact of features on individual output results.
[0037] In step 2, the SHAP nested XGBoost method is used to filter variables. SHAP is based on the calculation of Shapley value, which is used to measure how features affect the dependent variable. Starting from an initial naive model, a new model is built and fitted based on the error of the observations in the sample set, and added to the existing model in an additive manner. This process is iterated repeatedly to form an integrated model.
[0038] Step 2 includes the following steps:
[0039] S2.1: By associating the model's predicted values with the SHAP interpretable model g(x′) using the sigmoid function, an interpretable XGBoost model is constructed, as shown in Equation (11):
[0040]
[0041] In equation (11), e -g(x′) This represents an exponential function with the natural constant e as its base.
[0042] S2.2: For ensemble tree models, when performing classification tasks, the model outputs a probability value. SHAP can calculate the Shapley value for each feature to measure the contribution of each feature to the final prediction. Assuming g represents the explanatory model, SHAP describes the explanatory model as the sum of the baseline value φ0 of the sample prediction and the Shapley values of all input features, as shown in Equation (12):
[0043]
[0044] In equation (12): φ j x′ is the Shapley value of the j-th feature of the sample; m is the number of features in the sample; j ∈{0,1} m Indicates feature x j Does it exist?
[0045]
[0046] In equation (13): z is the set of all feature vectors of the sample. x 1 ,x 2 ,…,x m This represents m different feature vectors.
[0047] z \j z contains no feature x j Feature subset; F x (z) is the predictive output of the interpretable XGBoost model when the input feature is z for sample x, F x (z) and F x (z \i The difference between the features x is the characteristic x. j Contribution to the prediction results.
[0048] The SHAP value for each feature represents the expected change in model predictions when that feature is used as a condition. For each feature, the SHAP value illustrates the feature's contribution to the overall prediction outcome, illustrating the difference between the average model prediction and the actual prediction for the instance.
[0049] Based on the above steps, the contribution of each feature to the model prediction results is decomposed and quantitatively mapped, and the deep learning of the power system short-term inertia prediction learning model is completed.
[0050] Step 3 includes the following steps:
[0051] S3.1: Construct a short-term inertia prediction framework for power systems. Divide the preprocessed dataset into training and testing sets, and train an interpretable XGBoost model through data reading, parameter setting, and other processes.
[0052] The specific framework for predicting the short-term inertia of power systems is as follows: Figure 2 As shown, the specific content involves short-term prediction of system inertia based on this framework. The process can be roughly divided into three parts: data preprocessing, model training, and result output. Specifically, based on historical data collected by WAMS, relevant physical quantities affecting system inertia prediction are extracted as input features. After preprocessing, a dataset suitable for model training is obtained. Then, the dataset is divided into a training set and a test set. The training set is used to train an interpretable XGBoost model, and the test set is used for model evaluation and result verification. Finally, the correlation between the output system inertia value and the features is analyzed, and the global and local impacts of the features on the short-term prediction model of power system inertia are visualized.
[0053] S3.2: Calculate the SHAP values of the variable in all samples using TreeSHAP, and use their average value as the importance value of the feature variable to obtain a global interpretation;
[0054] S3.3: Perform short-term prediction of system inertia, analyze the correlation between the output system inertia value and its characteristics, and visualize the global and local impact of the characteristics on the short-term prediction model of power system inertia.
[0055] The interpretable XGBoost model built based on the SHAP attribution method satisfies the characteristics of local accuracy, allowing missing values, and consistency. Local accuracy explains the model's prediction results for individual samples. Missing values indicate that the features of a sample do not contribute to the model's prediction; XGBoost does not impute variables. When the model structure changes, the marginal contribution of the input features is consistent with the change in the Shapley values of the input features, and the additivity, dummy nature, and symmetry of the Shapley values themselves are consistent with SHAP.
[0056] The short-term prediction model for power system inertia is explained and analyzed from both global and local perspectives, and is expressed as follows:
[0057] (1) Global interpretability: Explain how the model makes decisions based on the entire feature space and model structure, parameters, etc.: According to Equation (13), the Shapley values of all features in the sample set are obtained. From the perspective of the entire sample, the average absolute value of the Shapley value of each feature is calculated. The magnitude of this value reflects the global contribution of the feature to the model output. In addition, based on the distribution relationship between the Shapley value of each feature and the value of the feature itself, the positive or negative correlation between the value of the feature and the model output is explored.
[0058] (2) Local interpretability: Focusing on a single sample without considering the complexity of the model: The output of a single sample can be expressed as the sum of the Shapley values of each feature in Equation (12), explaining how the features affect the output of a single sample, and thus determining the local dominant feature of the sample; combined with the positive and negative correlation of features in the global analysis, clarifying the influence of features on the output of the sample being too high or too low.
[0059] S3.4: For results predicted by the short-term prediction model of power system inertia, the mean absolute error (MAE), mean squared error (MSE), mean absolute percentage error (MAPE), and coefficient of determination (R²) are used. 2 Several methods are used for evaluation, as shown in equations (14) to (17):
[0060]
[0061]
[0062]
[0063]
[0064] In the formula, i is the sample number; n is the number of samples; The predicted system inertia value; y i This is the actual value of the system inertia.
[0065] Among them, the smaller the values of MAE, MSE, and MAPE, the better the model fit. 2 The larger the value, the better the model fit.
[0066] This invention provides a short-term prediction method for power system inertia based on the SHAP-XGBoost algorithm, with the following technical advantages:
[0067] 1) The interpretable XGBoost model constructed in this invention quantifies the impact of features on short-term predictions of system inertia in a consistent manner. Global interpretability uncovers the key physical quantities affecting system inertia, while local interpretability makes causal judgments on each prediction result, improving the reliability of the prediction results.
[0068] 2) This invention utilizes the positive / negative relationship between SHAP values and target feature values, combined with domain knowledge to interpret features. This method can decompose and quantitatively map the contribution of features in each sample to the model's prediction results. This not only ensures the short-term prediction accuracy of system inertia but also makes the black-box model easier to understand, improving the reliability of the prediction.
[0069] 3) This invention makes full use of the interpretability mechanism of the XGBoost machine learning model, which not only ensures a high accuracy rate in short-term prediction of power system inertia, but also allows us to grasp the feature correlations within the model, which is beneficial for power grid dispatching departments to formulate corresponding control measures. Attached Figure Description
[0070] Figure 1 This is a framework diagram of the interpretable XGBoost algorithm.
[0071] Figure 2 This is a flowchart for short-term prediction of power system inertia.
[0072] Figure 3 This is a comparison chart of the actual and predicted values of power system inertia.
[0073] Figure 4 This is a comparison chart of the importance of features in power system inertia prediction models.
[0074] Figure 5 This is a graph showing the relationship between Shapley values and load demand characteristics.
[0075] Figure 6 This is a graph showing the relationship between the Shapley values and photovoltaic power characteristics.
[0076] Figure 7 The image shows the predicted system inertia at 00:00 on December 31st of a certain year.
[0077] Figure 8 The image shows the predicted system inertia at 12:00 on December 31st of a certain year. Detailed Implementation
[0078] A short-term prediction method for power system inertia based on the SHAP-XGBoost algorithm includes the following steps:
[0079] Step 1: Considering the spatiotemporal variation mechanism of power system frequency, determine the input characteristics of short-term inertia prediction of power system, and construct a short-term inertia prediction learning model based on XGBoost.
[0080] The mechanism of spatiotemporal frequency variation in power systems is as follows:
[0081] When a large generator in a power system suddenly fails and shuts down, the resulting active power deficit causes fluctuations in the system frequency. Existing research shows that power system frequency variations have spatiotemporal distribution characteristics. With the transformation and upgrading of my country's power system, synchronous machines are gradually being replaced in new power systems dominated by new energy sources, altering the characteristics and form of system inertia. The resulting low inertia problem changes the system frequency characteristics, causing multiple frequency safety incidents. This indicates that insufficient system inertia support capacity is a significant factor leading to weakened system stability. Therefore, rapid and accurate prediction of the short-term inertia of the power system can help to understand the system inertia level in advance and provide early warning of when the risk of inertia weakness will occur.
[0082] The interpretable XGBoost model based on SHAP is adopted, and its algorithm framework diagram is as follows. Figure 1 As shown, in step 1, firstly, historical data is collected based on the Wide Area Measurement and Management System (WAMS), and relevant physical quantities affecting system inertia prediction are extracted as input features; considering the spatiotemporal variation mechanism of power system frequency, a short-term inertia prediction learning model based on XGBoost is constructed. The sample dataset is described as shown in equations (1) to (2), with each row of the input sample set corresponding to the output sample set:
[0083]
[0084] Y = [y1, y2, ..., y n ] T (2);
[0085] In the formula, X is the input sample dataset; Y is the output sample dataset; the superscript m is the dimension of the input feature; and the subscript n is the number of input samples. Each row of X represents an input sample.
[0086] When selecting input features, it is necessary to ensure that they can reflect the inertia characteristics of the system well, and that the calculation is fast in time. In order to ensure the accuracy of power system inertia prediction, appropriate features are selected based on the power system inertia response equation in the dynamic change of active power and frequency, as shown in equation (3).
[0087]
[0088] Among them, H sys and D sysThese represent the system inertia and system damping, respectively; ΔP is the system power change rate; Δf COI This refers to the frequency deviation of the inertia center. As shown in equation (3), the factors affecting system inertia include frequency and the active power of various energy sources. Therefore, system frequency and load demand should be considered when selecting input characteristics.
[0089] During feature data acquisition, it is difficult to avoid the presence of noisy data such as missing values and outliers. Therefore, data preprocessing is required before use. This involves cleaning and imputing the dataset. Missing values can be filled directly through numerical calculations, and outliers can be detected and replaced with the mean. Finally, a dataset suitable for model training is obtained.
[0090] Short-term inertia prediction learning model based on XGBoost:
[0091] XGBoost is an ensemble learning model that uses boosting and employs CART (Classification and Regression Tree) as its base learner. Details are as follows:
[0092]
[0093] In the formula: x is the model's predicted value. i For the i-th sample; f k Let be an independent function in the space; F is the function space composed of all CARTs. XGBoost adds a regularization term to the loss function to prevent overfitting, and its objective function is shown below:
[0094]
[0095]
[0096] In equation (5): the first term represents the error between the predicted value and the actual value, and the second term is the regularization term. In equation (6): T is the number of leaf nodes; ω j γ represents the weight of the leaf nodes; γ and λ are pre-defined hyperparameters used to control the number and score of leaf nodes, respectively. Since the optimization parameters of the objective function are a tree model, iteratively decomposed into a tree learning process. While keeping the original model unchanged, incremental training is used to minimize the objective function, updating the objective function after each iteration as follows:
[0097]
[0098] The second-order Taylor expansion transforms equation (7) into a function of the independent variable ω. j The form of a quadratic function in one variable. Let I jGiven the sample set of node j, obtain the optimal solution. The corresponding optimal objective function value is:
[0099]
[0100]
[0101] During training, the splitting criterion of the spanning tree model adopts a greedy algorithm, selecting the feature node that maximizes the gain of the objective function before and after the node split as the splitting point, as shown below:
[0102]
[0103] In the formula, G L H L G R H R These are the first and second derivatives of the left and right subtrees of the current node during the split, respectively.
[0104] Step 2: Based on the short-term inertia prediction learning model established in Step 1, considering the impact of the lack of interpretability of traditional machine learning models, an interpretable learning algorithm based on SHAP-XGBoost is proposed to realize the deep learning of the short-term inertia prediction learning model.
[0105] The specific impacts of the lack of interpretability in traditional machine learning models are as follows:
[0106] Machine learning models are categorized into white-box models and black-box models. Simple linear models and single-subject decision trees belong to white-box models, where the way they map input to output is fully understandable. Random forests composed of many decision trees, boosting trees, and deep neural networks, on the other hand, belong to black-box models. The input-to-output mapping in these models is extremely complex, making it nearly impossible to fully understand the machine's internal workings. The XGBoost model, built based on Shapley's algorithm, uses Shapley values to globally interpret the importance of each feature, allowing for a multi-dimensional analysis of the black-box structure and the impact of features on individual output results.
[0107] The SHAP nested XGBoost method is used to select variables. Starting from an initial naive model, a new model is built and fitted based on the error of the observations in the sample set. This model is then added to the existing model in an additive manner. This process is iterated repeatedly to form an ensemble model. Specifically, the model predictions are associated with the SHAP interpretable model g(x′) through the sigmoid function to construct an interpretable XGBoost model, as shown in Equation (11).
[0108]
[0109] Then, based on the Shapley value calculated by cooperative game theory, SHAP describes the explanatory model as the sum of the baseline value φ0 of the sample prediction and the Shapley values of all input features, as shown in Equation (12):
[0110]
[0111]
[0112] In equation (12): φ j x is the Shapley value of the j-th feature of the sample; m is the number of features in the sample; x ′j ∈{0,1} m Indicates feature x j Does it exist? In equation (13): z is the set of all feature vectors of the sample. x 1 ,x 2 ,…,x m This represents m distinct feature vectors. z \j z contains no feature x j A subset of features. F x (z) is the predictive output of the interpretable XGBooost model when the input feature is z for sample x, F x (z) and F x (z \i The difference between the features x is the characteristic x. j Contribution to the prediction results.
[0113] Based on the above steps, the contribution of each feature to the model prediction results is decomposed and quantitatively mapped, and the deep learning of the short-term inertia prediction model of the power system is completed.
[0114] Step 3: Construct a short-term inertia prediction framework for power systems and realize the online deployment and application of prediction models.
[0115] A framework for predicting the short-term inertia of power systems is constructed, and its specific prediction process is as follows: Figure 2 As shown, the process can be roughly divided into three parts: data preprocessing, model training, and result output. Specifically, based on historical data collected by WAMS, relevant physical quantities affecting system inertia prediction are extracted as input features, and preprocessed to obtain a dataset suitable for model training. Then, the dataset preprocessed in step 1 is divided into a training set and a test set. The training set is used to train the interpretable XGBoost model, and the test set is used for model evaluation and result verification.
[0116] Simultaneously, TreeSHAP is used to calculate the SHAP value of the variable in all samples, and the average value is used as the importance value of the feature variable to obtain a global interpretation. Then, short-term prediction of system inertia is performed, the correlation between the output system inertia value and the feature is analyzed, and the global and local effects of the feature on the short-term prediction model of power system inertia are visualized.
[0117] The interpretable XGBoost model built based on the SHAP attribution method satisfies the characteristics of local accuracy, allowance of missing values, and consistency. Local accuracy explains the model's prediction results for individual samples. Missing values indicate that the features of a sample do not contribute to the model's prediction; XGBoost does not impute variables. When the model structure changes, the marginal contribution of the input features is consistent with the change in the Shapley values of the input features, and the additivity, dummy nature, and symmetry of the Shapley values themselves are consistent with SHAP. The model's interpretability is analyzed from both global and local dimensions, as follows:
[0118] (1) Global interpretability: Explaining how the model makes decisions based on the entire feature space, model structure, parameters, etc.: According to Equation (13), the Shapley values of all features in the sample set are obtained. Considering the entire sample, the average absolute value of the Shapley value of each feature is calculated. The magnitude of this value reflects the global contribution of the feature to the model output. In addition, based on the distribution relationship between the Shapley value of each feature and the feature's own value, the positive or negative correlation between the value of the feature and the model output is explored.
[0119] (2) Local interpretability: Focusing only on a single sample without considering the complexity of the model: The output of a single sample can be expressed as the sum of the Shapley values of each feature in Equation (12), explaining how the features affect the output of a single sample, and thus determining the local dominant feature of the sample. Combining the positive and negative correlation of features in the global analysis, the influence of features on the output of the sample is clarified as either too high or too low.
[0120] The predictive methods use the following metrics to measure the predicted outcomes: Mean Absolute Error (MAE), Mean Squared Error (MSE), Mean Absolute Percentage Error (MAPE), and Coefficient of Determination (R²). 2 ), whose definition is shown in equations (14)-(17):
[0121]
[0122]
[0123]
[0124]
[0125] In the formula, i is the sample number; N is the number of samples; The predicted system inertia value; y i This represents the actual value of the system inertia. Among these, smaller values for MAE, MSE, and MAPE indicate a better model fit, and R0 represents the actual value of the system inertia. 2 The larger the value, the better the model fit.
[0126] Example:
[0127] An interpretable XGBoost short-term inertia prediction model based on SHAP was used to predict the short-term system inertia of a country's power grid. First, measured data of the national power grid of a certain country from January 1 to December 31 of a certain year were collected based on WAMS, with a time resolution of 5 minutes. The input features selected included meteorological features, power of conventional units and new energy sources, and load demand. The 28-dimensional input feature types collected are shown in Table 1.
[0128] Table 1 shows the input feature set for system inertia prediction.
[0129] Table 1 Input features for system inertia prediction
[0130]
[0131]
[0132] Then, use the MAE indicator, MSE indicator, MAPE indicator, and R... 2 Four indicators were used to evaluate the model. Since the training and optimization of the model is random, the average of the five calculation results for each model was taken. The results are shown in Table 2.
[0133] Table 2 shows the comparison of errors with mainstream machine learning algorithms.
[0134] Table 2 Comparison with error results of mainstream machine learning algorithms
[0135]
[0136] The results show that the XGBoost model achieves the highest prediction accuracy on the test data, with R0... 2A value of 0.985 means it can accurately predict the short-term trend of power system inertia, as shown in its prediction curve. Figure 3 As shown.
[0137] Among ensemble algorithms, GradientBoost, Bagging, and ExtraTree have R... 2 The evaluation scores are all above 0.90, while AdaBoost's score is only 0.815. AdaBoost's other evaluation metrics are on a completely different order of magnitude from those of ensemble algorithms. The mean absolute error of the XGBoost model is 2.911%, the mean squared error is 0.172%, and the mean absolute percentage error is 0.538%, demonstrating accurate predictions that far outperform other machine learning models.
[0138] The interpretable XGBoost algorithm analyzes and interprets its output results from both global and local interpretability perspectives. From a global perspective, the factors influencing system inertia are ranked according to feature importance, resulting in the feature importance ranking of the SHAP-based interpretable XGBoost model, as follows: Figure 4 As shown. Figure 4 The points in the graph represent each sample, and the horizontal axis represents the Shapley value of the feature. The distribution of each feature's Shapley value is correlated with the magnitude of the feature value, represented by different colors. The color distribution of a feature indicates its impact on the model; the redder the sample point, the larger its Shapley value. The vertical axis ranks the importance of the 28-dimensional feature values, with features arranged from most important to least important; the larger the feature value, the more important it is. Figure 4 It can be seen that for power system inertia prediction models, the most important characteristics are load demand, photovoltaic power, and coal-fired power. Among them, load demand has the largest eigenvalue, and its numerical distribution variance is significantly higher than other characteristics, with a large number of Shapley values clustered below the average. The blue areas of low load demand have a positive impact on the model's prediction results, while the red areas of high load demand have a negative impact. This color distribution indicates that the higher the load demand, the greater the system inertia value, which is consistent with the understanding of actual power system operation.
[0139] Taking load demand and photovoltaic power characteristics as an example, Figure 5 and Figure 6The relationship between the respective Shapley values and the feature's own values is further illustrated. It can be observed that when the load demand is less than 35000MW, the Shapley value of the feature is negatively correlated with the feature itself, indicating that the model's prediction of system inertia decreases as load demand increases. When photovoltaic output is zero, the Shapley value of the feature is less than zero, indicating that the system inertia is more likely to be lower than the baseline value. From a physical perspective, the system inertia increases with increasing load demand, indicating that more synchronous generators are started. However, when load demand increases further, the instantaneous power gap burdens the grid operation, and the system may face the risk of low inertia. When photovoltaic resources are scarce, the equivalent system inertia decreases.
[0140] From a local perspective, we selected samples from 00:00 and 12:00 on December 31st of that year for interpretation. SHAP interpretation helps to understand how the input features are predicted. The prediction results at the two time points are... Figure 7 and Figure 8 In the diagram, the red features indicate positive Shapley values, which positively contribute to the predicted values, increasing the predicted system inertia. Larger colored blocks have a greater impact on the model results. At 0:00, the positive impact of load demand is greatest, while the negative impact of photovoltaic power is greatest. The model's predicted output of 5.559 is higher than the baseline value of 5.378, indicating that the system is not at a low inertia level at this time. Conversely, at 12:00, the positive impact of photovoltaic power is greatest, while the negative impact of load demand is greatest. The model's predicted output at 12:00 is lower than the baseline value, indicating a further downward trend in system inertia. In severe cases, there is a risk of load shedding / shutdown in low-inertia operation scenarios.
[0141] Combination Figure 5 and Figure 6 The analysis of the positive and negative correlation trends of the reflected characteristics Figure 7 and Figure 8 The load demand at 0:00 and 12:00 is defined by 35000MW, resulting in 27708MW and 37190MW respectively, increasing the model's prediction inertia for the corresponding samples by 0.160 and decreasing it by 0.142. The impact of features on model decisions varies across different samples, but globally important features such as load demand and photovoltaic characteristics have a significant impact on the prediction results for different samples. Figure 4 The conclusions are consistent.
Claims
1. A short-term prediction method for power system inertia based on the SHAP-XGBoost algorithm, characterized in that... Includes the following steps: Step 1: Determine the input characteristics of short-term inertia prediction for the power system and construct a short-term inertia prediction learning model based on XGBoost; Step 2: Based on the short-term inertia prediction learning model established in Step 1, an interpretive learning algorithm based on SHAP-XGBoost is proposed to realize the deep learning of the short-term inertia prediction learning model. Step 3: Construct a short-term inertia prediction framework for the power system to achieve power system inertia prediction using the prediction model; In step 3, the short-term prediction model for power system inertia is interpreted and analyzed from both global and local dimensions, as follows: (1) Global interpretability: Explain how the model makes decisions based on the entire feature space and model structure, parameters, etc.: According to Equation (13), the Shapley values of all features in the sample set are obtained. From the perspective of the entire sample, the average absolute value of the Shapley value of each feature is calculated. The magnitude of this value reflects the global contribution of the feature to the model output. Furthermore, based on the distribution relationship between the Shapley value of each feature and the value of the feature itself, we can explore the positive or negative correlation between the value of the feature and the model output. (13); In equation (13): It is the set of all feature vectors of the sample. ; This represents m different feature vectors; yes The middle does not contain features A subset of features; Is the XGBoost model interpretable for samples? Input features are The predicted output obtained at that time and The difference is the characteristic Contribution to the prediction results; (2) Local interpretability: Focusing on a single sample without considering the complexity of the model: The output of a single sample can be expressed as the sum of the Shapley values of each feature in Equation (12), explaining how the features affect the output of a single sample, and thus determining the local dominant feature of the sample; combined with the positive and negative correlation of features in the global analysis, clarifying the influence of features on the output of the sample being too high or too low. set up g Representing the explanatory model, SHAP describes the explanatory model as a baseline for sample predictions. The sum of all input feature Shapley values is in the form shown in equation (12): (12); In equation (12): It is the sample number Shapley values for each feature; It is the number of features in the sample; Representation of features Does it exist? 2. The short-term prediction method for power system inertia based on the SHAP-XGBoost algorithm according to claim 1, characterized in that: In step 1, historical data is first collected based on the Wide Area Measurement and Management System (WAMS), and relevant physical quantities that affect the prediction of system inertia are extracted as input features, which serve as the dataset for training the prediction learning model. Wherein: The sample dataset is described as shown in equations (1) to (2), and each row of the input sample set corresponds to the output sample set: (1); (2); In the formula, It is the input sample dataset; This is the output sample dataset; superscript It refers to the dimension of the input feature; subscript This is the number of input samples; where, Each line represents an input sample; Based on the power system inertia response equation in the dynamic change of active power and frequency, as shown in equation (3), appropriate characteristics are selected; (3); In equation (3), and These are system inertia and system damping, respectively. It is the system power change rate. It is the frequency deviation of the inertia center; as shown in equation (3), the factors affecting the system inertia are frequency and the active power of various energy sources; therefore, the system frequency and load demand should be considered when selecting input characteristics.
3. The short-term prediction method for power system inertia based on the SHAP-XGBoost algorithm according to claim 1, characterized in that: In step 1, the short-term inertia prediction learning model based on XGBoost is as follows: XGBoost uses CART (Classification and Regression Tree) as the base learner, as shown in Equation (4): (4) In the formula: These are the model's predicted values; For the first One sample; Let it be an independent function in space; Let CART be the function space. XGBoost adds a regularization term to the loss function to prevent overfitting. Its objective function is shown below: (5) (6) In equation (5): the first term represents the error between the predicted value and the actual value, and the second term is the regularization term; In equation (6): It is the number of leaf nodes; These are the weights of the leaf nodes; and These are pre-defined hyperparameters used to control the number of leaf nodes and the score, respectively. Since the optimization parameters of the objective function are a tree model, it is iteratively decomposed into a tree learning process. While keeping the original model unchanged, incremental training is used to minimize the objective function, and the objective function is updated after each iteration as follows: (7) The second-order Taylor expansion transforms equation (7) into a function of the independent variable. The form of a quadratic function in one variable; make , , It is a node j The optimal solution is obtained from the sample set. The corresponding optimal objective function value is: (8) (9) During training, the splitting criterion of the spanning tree model adopts a greedy algorithm, selecting the feature node that maximizes the gain of the objective function before and after the node split as the splitting point, as shown below: (10) In the formula, , , , These are the first and second derivatives of the left and right subtrees of the current node during the split, respectively.
4. The short-term prediction method for power system inertia based on the SHAP-XGBoost algorithm according to claim 1, characterized in that: In step 2, the SHAP nested XGBoost method is used to filter variables. SHAP is based on the calculation of Shapley value, which is used to measure how features affect the dependent variable. Starting from an initial naive model, a new model is built and fitted based on the error of the observations in the sample set, and added to the existing model in an additive manner. This process is iterated repeatedly to form an integrated model.
5. The short-term prediction method for power system inertia based on the SHAP-XGBoost algorithm according to claim 4, characterized in that: Step 2 includes the following steps: S2.1: Compare the model predictions with the SHAP explanation model using the sigmoid function. Correspondingly, an interpretable XGBoost model is constructed, as shown in Equation (11): (11); In equation (11), This represents an exponential function with the natural constant e as its base. S2.2: Let g Representing the explanatory model, SHAP describes the explanatory model as a baseline for sample predictions. The sum of all input feature Shapley values is in the form shown in equation (12): (12); In equation (12): It is the sample number Shapley values for each feature; It is the number of features in the sample; Representation of features Does it exist? (13); In equation (13): It is the set of all feature vectors of the sample. ; This represents m different feature vectors; yes The middle does not contain features A subset of features; Is the XGBoost model interpretable for samples? Input features are The predicted output obtained at that time and The difference is the characteristic Contribution to the prediction results; Based on the above steps, the contribution of each feature to the model prediction results is decomposed and quantitatively mapped, and the deep learning of the power system short-term inertia prediction learning model is completed.
6. The short-term prediction method for power system inertia based on the SHAP-XGBoost algorithm according to claim 5, characterized in that: Step 3 includes the following steps: S3.1: Construct a short-term inertia prediction framework for power systems. Divide the preprocessed dataset into training and testing sets. Train an interpretable XGBoost model by reading data and setting parameters. S3.2: Calculate the SHAP values of the variable in all samples using TreeSHAP, and use their average value as the importance value of the feature variable to obtain a global interpretation; S3.3: Perform short-term prediction of system inertia, analyze the correlation between the output system inertia value and its characteristics, and visualize the global and local impact of the characteristics on the short-term prediction model of power system inertia.
7. The short-term prediction method for power system inertia based on the SHAP-XGBoost algorithm according to claim 6, characterized in that: Also includes: S3.4: For results predicted by the short-term prediction model of power system inertia, the mean absolute error (MAE), mean squared error (MSE), mean absolute percentage error (MAPE), and coefficient of determination (R²) are used. 2 Several methods are used for evaluation, as shown in equations (14) to (17): (14); (15); (16); (17); In the formula, Number the sample; The number of samples; The predicted system inertia value; R represents the actual value of the system inertia; where, the smaller the MAE, MSE, and MAPE, the better the model fit. 2 The larger the value, the better the model fit.
Citation Information
Patent Citations
XGBoost algorithm-based frequency characteristic prediction method after disturbance of power system
CN111639463A
Comprehensive energy system load prediction method and device
CN114997488A