Line loss prediction method and system based on GRU model
By adopting a line loss prediction method based on GRU model in the power system, combining the Attention layer and LightGBM model, the problem of large deviation in line loss prediction results in the existing technology is solved, and higher prediction accuracy and robustness are achieved. Support is provided by intelligent management of power systems.
Patent Information
- Application Number
- CN202510040183.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-10
- Publication Date
- 2025-02-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prior art is difficult to fully capture the complexity and nonlinear characteristics of time series data in line loss prediction in power systems, resulting in large deviations in prediction results and insufficient prediction accuracy and robustness of deep learning models.
The line loss prediction method based on the GRU model is adopted, and the line loss prediction is predicted by obtaining historical line loss data for preprocessing, and the GRU model including the Attention layer is constructed, and the line loss prediction is performed by combining multi-source data such as seasonal characteristics and weather data.
It enhances the ability to capture long-term time series, improves the accuracy and robustness of model prediction, and provides strong support for the intelligent management of power systems.
Smart Images

Figure CN119442121A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power system automation, and in particular to a line loss prediction method and system based on a GRU model. Background Art
[0002] In the power system, accurate prediction of line loss is the key to improving operational efficiency and reducing costs. Existing prediction methods mostly rely on traditional statistical models. Due to the complex changes in power load over time, traditional models are difficult to fully capture the complexity and nonlinear characteristics of time series data, resulting in large deviations in prediction results. In recent years, the rapid development of deep learning technology has provided new ideas for time series prediction. Although deep learning models have made progress, they still have problems such as insufficient prediction accuracy and robustness. Summary of the invention
[0003] The purpose of this application is to overcome the defects of the prior art and provide a line loss prediction method and system based on the GRU model.
[0004] In a first aspect, the present application provides a line loss prediction method based on a GRU model, comprising the following steps: Get historical line loss data; Preprocessing the historical line loss data; Obtaining input features based on the preprocessed historical line loss data, wherein the input features include a training set, a validation set, and a test set; Training a GRU model and a LightGBM model based on the input features; the training of the GRU model based on the input features includes: constructing a basic GRU model, the basic GRU model includes multiple network layers, the multiple network layers include: an input layer, a loop layer and an output layer; adding an Attention layer between the loop layer and the output layer to obtain a GRU model; using the training set to train the GRU model; using the validation set to evaluate the model performance of the trained GRU model, and adjusting the number of layers of the network layer and the number of neurons in each layer of the network layer based on the evaluated model performance; using the grid search method to optimize the hyperparameters of the GRU model; using the test set to evaluate the prediction performance of the GRU model; Line loss prediction is performed based on the trained GRU model to obtain the first prediction result; Line loss prediction is performed based on the trained LightGBM model to obtain the second prediction result; A line loss prediction result is obtained based on the first prediction result and the second prediction result.
[0005] Optionally, the preprocessing of the historical line loss data includes: Cleaning the historical line loss data to remove abnormal values in the historical line loss data and fill in missing values in the historical line loss data; The cleaned historical line loss data is normalized.
[0006] Optionally, after acquiring the historical line loss data, the method further includes: creating hysteresis feature data based on the historical line loss data, wherein the hysteresis feature data includes historical line loss data at multiple time points; and the input feature includes at least one of the pre-processed historical line loss data and the hysteresis feature data.
[0007] Optionally, obtaining the input feature based on the preprocessed historical line loss data includes: screening the preprocessed historical line loss data to obtain the input feature.
[0008] Optionally, the line loss prediction method based on the GRU model further includes: acquiring seasonal characteristic data and weather data; the input features also include the seasonal characteristic data and the weather data.
[0009] Optionally, the input features are input into a trained GRU model for line loss prediction to obtain a first prediction result; the input features and the first prediction result are input into a trained LightGBM model for line loss prediction to obtain a second prediction result.
[0010] Optionally, obtaining a line loss prediction result based on the first prediction result and the second prediction result includes: Performing a weighted average of the first prediction result and the second prediction result to obtain the line loss prediction result; or The first prediction result and the second prediction result are input into a meta-learner for training to obtain the line loss prediction result.
[0011] Optionally, after obtaining the line loss prediction result based on the first prediction result and the second prediction result, the method further includes: Monitoring the prediction error of the GRU model, and adjusting parameters of the GRU model when the prediction error of the GRU model is abnormal; and / or Monitor the prediction error of the LightGBM model, and adjust the parameters of the LightGBM model when there is an abnormality in the prediction error of the LightGBM model.
[0012] In a second aspect, the present application also provides a line loss prediction system based on a GRU model, comprising: Data acquisition module, used to obtain historical line loss data; A preprocessing module, used for preprocessing the historical line loss data; An input feature acquisition module, used to obtain input features based on the preprocessed historical line loss data; A training module, used for training a GRU model and a LightGBM model based on the input features; A first prediction module, used for performing line loss prediction based on the trained GRU model to obtain a first prediction result; The second prediction module is used to predict line loss based on the trained LightGBM model to obtain a second prediction result; A line loss prediction module is used to obtain a line loss prediction result based on the first prediction result and the second prediction result.
[0013] The present application provides a line loss prediction method and system based on a GRU model, which obtains historical line loss data; preprocesses the historical line loss data; obtains input features based on the preprocessed historical line loss data; trains a GRU model and a LightGBM model based on the input features; predicts line loss based on the trained GRU model to obtain a first prediction result; predicts line loss based on the trained LightGBM model to obtain a second prediction result; obtains a line loss prediction result based on the first prediction result and the second prediction result; through the GRU model and the LightGBM model, the ability to capture long time series can be enhanced, the accuracy and robustness of model prediction can be improved, and strong support can be provided for the intelligent management of power systems.
[0014] In order to make the above features and advantages of the invention more obvious and easy to understand, embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0016] Figure 1 This is a flowchart of a line loss prediction method based on a GRU model provided in one embodiment of the present application.
[0017] Figure 2 This is a flowchart of training the GRU model based on the input features in step S40 of the line loss prediction method based on the GRU model provided in one embodiment of the present application.
[0018] Figure 3This is a schematic diagram of the structure of a line loss prediction system based on a GRU model provided in another embodiment of the present application. DETAILED DESCRIPTION
[0019] In order to make the purpose and technical solution of the embodiment of the present application clearer, the technical solution of the embodiment of the present application will be clearly and completely described in conjunction with the drawings of the embodiment of the present application. Obviously, the described embodiment is a part of the embodiment of the present application, not all of the embodiments. Based on the described embodiment of the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0020] In one embodiment, see Figure 1 The present application provides a line loss prediction method based on a GRU model. The line loss prediction method based on a GRU model may include the following steps: S10~S70.
[0021] S10: Obtain historical line loss data.
[0022] S20: Preprocessing the historical line loss data.
[0023] S30: Obtaining input features based on the preprocessed historical line loss data.
[0024] S40: Training a GRU model and a LightGBM model based on the input features.
[0025] S50: Perform line loss prediction based on the trained GRU model to obtain a first prediction result.
[0026] S60: Perform line loss prediction based on the trained LightGBM model to obtain a second prediction result.
[0027] S70: Obtain a line loss prediction result based on the first prediction result and the second prediction result.
[0028] In the line loss prediction method based on the GRU model of the present application, the GRU model and the LightGBM model can enhance the ability to capture long time series, and improve the accuracy and robustness of the model prediction.
[0029] In step S10, refer to Figure 1 In step S10, historical line loss data is obtained.
[0030] As an example, historical line loss data is obtained from the power system. The historical line loss data may include: daily data, monthly data, annual data, transmission line data, substation data, distribution line data, resistance loss data, transformer loss data and other loss data (such as corona loss, etc.); specifically, the historical line loss data may also include time-related features, grid structure-related features, loss type-related features, data quality-related features and related factor-related features, etc. Obtaining multi-source data from the power system and meteorological departments enriches the prediction basis and enables the model to analyze line loss from multiple angles.
[0031] As an example, daily data can be the daily line loss electricity and the daily average line loss rate. Among them, the daily line loss electricity is the difference between the daily power supply and the power sales, which is the most intuitive line loss data. For example, the power supply in a certain power supply area on a certain day is 10,000 kWh, and the power sales is 9,500 kWh, then the daily line loss electricity is 500 kWh. The daily average line loss rate is calculated by the ratio of the daily line loss electricity to the daily power supply. For example, the daily average line loss rate in the above example is .
[0032] As an example, the monthly data can be the monthly line loss electricity summary and the monthly average line loss rate. The monthly line loss electricity summary is obtained by adding up the daily line loss electricity in a month. It helps to analyze the line loss situation over a longer period of time. For example, the total line loss electricity of a substation in a month can reflect the operating efficiency of the substation in this month. The monthly average line loss rate is calculated in a similar way to the daily average line loss rate, which is the ratio of the monthly line loss electricity to the monthly power supply. At the same time, the line loss rates of different months can also be compared to observe the impact of seasonal changes and other factors on line loss. For example, in summer, due to the high temperature and heavy power load, the resistance of the line increases due to the increase in temperature, which may cause the line loss rate to be higher than in winter.
[0033] As an example, the annual data can be the total annual line loss and the annual average line loss rate. The total annual line loss is the accumulation of the line loss in each month of the year, which is crucial for evaluating the annual operation loss of the power grid. The annual average line loss rate is also the ratio of the annual line loss to the annual power supply. In addition, the changing trend of the line loss rate between years can also be analyzed to evaluate the implementation effect of measures such as power grid transformation and energy-saving measures.
[0034] As an example, transmission line data may include the line loss rate of the transmission line, and the line loss quantity of transmission lines of different voltage levels (such as 110kV, 220kV, 500kV, etc.). For example, the line loss quantity of a 220kV transmission line in a certain period of time can help power operation and maintenance personnel determine whether the operation of the line is normal. The line loss rate of the transmission line can reflect the power transmission efficiency of the transmission line; for long-distance transmission lines, the line loss may be affected by multiple factors such as line length, conductor material, and line load.
[0035] As an example, substation data may include: the comprehensive line loss of each substation and the line loss rate of the substation. Among them, the comprehensive line loss of each substation may include transformer loss and in-station equipment loss. For example, the in-station line loss of a 110kV substation is the sum of the power losses of all equipment in the substation. The line loss rate of a substation is used to evaluate the efficiency of the substation in the process of power conversion and distribution. The line loss rates of substations of different types (such as hub substations, terminal substations) and sizes may vary.
[0036] As an example, distribution line data may include: the line loss rate of distribution lines and the line loss electricity of distribution lines in different areas (such as by different blocks in the city and different villages in the countryside). The line loss electricity of distribution lines in different areas helps to locate local areas with higher line losses. For example, if the line loss electricity of distribution lines in a certain block is too high, it may be caused by aging of the lines in the area, electricity theft, or unreasonable load distribution. The line loss rate of distribution lines is an important indicator to measure the efficiency of power distribution of distribution lines. By analyzing the line loss rate of distribution lines, targeted loss reduction measures can be taken, such as optimizing line layout and replacing high-loss equipment.
[0037] As an example, the resistance loss data may include: the power loss data caused by the wire resistance, the resistance loss rate of different line segments or equipment. Among them, the power loss data caused by the wire resistance is the main component of the line loss, which is related to the length of the wire, the cross-sectional area, the resistivity of the material and the current passing through. For example, according to the formula (where is the power loss, is the current, and is the resistance), the resistance loss of the wire under a certain current can be calculated. The resistance loss rate of different line segments or equipment can be obtained by the ratio of the resistance loss power to the total power supply, which is used to evaluate the proportion of resistance loss in the total line loss.
[0038] As an example, transformer loss data may include: transformer no-load loss (iron loss) and load loss (copper loss) data, transformer loss rate. Among them, no-load loss is the loss generated when the transformer is running at no load, which is mainly composed of eddy current loss and hysteresis loss in the iron core; load loss is the loss caused by winding resistance when the transformer is running with load. For example, the no-load loss of a 1000kVA transformer may be 1kW, and the load loss is related to the load rate. The transformer loss rate is the ratio of the transformer loss to the power supply passing through the transformer, which is used to measure the operating efficiency of the transformer. In the power grid, there are a large number of transformers, and transformer loss is an important part of line loss. Reducing transformer loss is of great significance to reducing overall line loss.
[0039] As an example, for high-voltage transmission lines, corona loss is a loss that cannot be ignored. Corona loss mainly occurs on the surface of high-voltage wires. When the electric field strength exceeds the breakdown strength of air, corona discharge will occur, resulting in power loss. Its data includes corona loss power and corona loss rate. The corona loss rate is the ratio of corona loss power to total power supply. The size of the corona loss rate is related to factors such as line voltage level and weather conditions (such as humidity and air pressure).
[0040] As an example, time-related features may include: timestamp, season features, weekday / weekend / holiday features. Among them, the timestamp can record the specific date and time when the line loss data is generated, accurate to the year, month, day, hour, etc. For example, "2023 - 05 - 10 14:00", which helps to analyze the changing rules of line loss in different time periods. For example, it is found that the high line loss in certain time periods may be related to the peak power consumption in that period. Seasonal features can convert time data into seasonal information, such as spring, summer, autumn and winter. For example, in summer, due to the increase in temperature, users use high-power electrical appliances such as air conditioners, which increases the power load, and the resistance of the line increases due to the increase in temperature, so that the line loss rate may be higher than in winter. Weekday / weekend / holiday features can distinguish the date type to which the data belongs. For example, industrial electricity demand is large on weekdays, while the proportion of residential electricity consumption may increase on weekends and holidays. The difference in electricity consumption patterns of different date types will affect the line loss. For example, some factories stop working on weekends, and the corresponding industrial line loss may be reduced.
[0041] As an example, the grid structure-related features may include: voltage level, line length, substation name / number. Among them, the voltage level may be 10kV, 35kV, 110kV, etc. The line loss of lines of different voltage levels is different. Generally speaking, the higher the voltage level, the smaller the current at the same power, and the relatively low resistance loss. For example, the line loss rate of a 110kV transmission line may be lower than that of a 10kV distribution line. The line length can record the actual length of the line in kilometers. The longer the line, the greater the resistance loss. For example, a 100-kilometer-long transmission line will have more line loss than a 50-kilometer-long line under the same conductor material, current and other conditions. The substation name / number is used to distinguish the line loss data corresponding to different substations. Different equipment parameters (such as transformer capacity, model, etc.) and load conditions of different substations will lead to differences in line loss. For example, a hub substation connects multiple transmission lines and distribution lines, has a heavy load, and the line loss situation may be more complicated than that of a terminal substation.
[0042] As an example, loss type-related features may include: resistance loss rate, transformer loss type (no-load / load), and corona loss degree (for high-voltage lines). Among them, the resistance loss rate is the ratio of the loss caused by the conductor resistance in the line loss to the total power supply. For example, if the resistance loss rate of a certain line is 3%, you can intuitively understand the proportion of resistance loss in the total line loss. It is related to the material (such as copper, aluminum), cross-sectional area, length, and current passing through the conductor. Transformers have no-load losses (mainly core losses) and load losses (mainly winding resistance losses); record the loss of transformers under different operating conditions. For example, the no-load loss of a 1000kVA transformer is 1kW, and the load loss is related to the load rate. By analyzing these data, the operating efficiency of the transformer and its contribution to the line loss can be evaluated. For high-voltage transmission lines, the corona loss power per kilometer of line can be used to measure it. For example, the corona loss power per kilometer of a 500kV high-voltage transmission line is 0.1 kWh. The degree of corona loss is related to factors such as line voltage level and weather conditions (humidity, air pressure).
[0043] As an example, data quality-related features may include: data integrity mark, data source reliability mark. Among them, the data integrity mark can mark whether the line loss data is complete, for example, whether the power supply or electricity sales data for a certain time period is missing. If the data is incomplete, it may affect the accuracy of the line loss calculation, and this part of the data needs to be specially processed or supplemented during analysis. The data source reliability mark can indicate whether the data comes from a high-precision meter, an automated monitoring system, or manual meter reading. The reliability of data from different sources is different. For example, the accuracy of data obtained by an automated monitoring system is usually higher than that of data obtained by manual meter reading.
[0044] As an example, the associated factors and related features may include: ambient temperature, load rate, etc. Among them, changes in ambient temperature will affect the line resistance and equipment operating efficiency. Recording ambient temperature data can help analyze the degree of its impact on line loss. For example, when the ambient temperature rises from 20°C to 30°C, the wire resistance will increase, resulting in increased resistance loss, and the line loss rate may increase accordingly. The load rate refers to the ratio of the actual load of a line or equipment to the rated load. A high load rate may lead to increased losses in the line and equipment. For example, when the load rate of a distribution line reaches 80%, the line loss rate may be a certain percentage higher than when the load rate is 40%, because the current increases at a high load rate and the resistance loss increases significantly.
[0045] In step S20, refer to Figure 1 In step S20, the historical line loss data is preprocessed.
[0046] For example, after obtaining historical line loss data from the power system, some data may be missing or abnormal due to various reasons (such as sensor failure, data transmission interruption, etc.). These missing values or abnormal values will destroy the integrity of the data and affect the model's learning of the overall characteristics of the data. Therefore, preprocessing the historical line loss data is a crucial step.
[0047] As an example, in step S20, the preprocessing of the historical line loss data may include the following steps: S201~S202.
[0048] S201: Clean the historical line loss data to remove abnormal values in the historical line loss data and fill in missing values in the historical line loss data.
[0049] S202: normalizing the cleaned historical line loss data.
[0050] As an example, the mean filling method, forward filling method, and interpolation method can be used to handle missing values. The appropriate method for missing value processing can be selected according to different data types. The mean filling method uses the mean of historical line loss data to fill missing values, the forward filling method uses the historical line loss data of the previous time point to fill missing values, and the interpolation method estimates missing values through linear interpolation or other interpolation methods. Since the forward filling method fills missing values with the values of the previous time point, it can maintain the continuity of the time series. When processing time series data, forward filling is usually a more effective choice. Through missing value processing, the missing data points are filled or processed by appropriate methods to ensure the integrity of the data, so that the model can learn based on complete data and avoid information loss and model deviation caused by missing data. Processing outliers can eliminate the interference of erroneous data, so that the data learned by the model can better reflect the actual system operation and improve the reliability and prediction accuracy of the model.
[0051] As an example, the cleaned historical line loss data is further normalized. The data can be scaled to the [0,1] interval through normalization. The minimum-maximum normalization method can be used. The specific implementation method can be expressed by the following formula: in, is the original data, is the normalized data, and are the minimum and maximum values of the feature (i.e. historical line loss data). Normalization can ensure that different features are compared on the same scale, thereby improving the training efficiency and prediction accuracy of the model, enabling the model to converge faster and reducing training time.
[0052] As an example, after normalization, lag feature data is further created based on the historical line loss data. By creating lag feature data, the time series characteristics of the data are fully utilized. The lag feature data includes historical line loss data at multiple time points; the input features include at least one of the preprocessed historical line loss data and the lag feature data. Lag features refer to creating new features using past values in time series data. In time series analysis, the value of a variable at a certain moment may be associated with its value at the previous moment. By creating lag features, this temporal dependency can be incorporated into the model to better capture the dynamic changes of the data. For example, for a time series data set, you can create past The features of each time point are used to enable the model to learn time dependencies. The specific implementation method is: in, Indicates the characteristic value at the current time point (historical line loss data), express By creating lagged feature data, the historical line loss data is extended in time, and the line loss values at past moments are introduced as new features. During the learning process, the model can better capture the trend and law of line loss changes over time, and improve the model's modeling ability for time series data. In this way, the model is helped to learn past line loss patterns, enabling the model to capture the time dependency of line loss.
[0053] As an example, after creating the hysteresis feature data, a chart tool may be used to perform a visual analysis on the hysteresis feature data to ensure the quality of the data and the validity of the features. The chart tool may use Matplotlib or Seaborn, and a time series graph, a histogram, etc. may be used to check the distribution and trend of the data, thereby providing a reliable basis for subsequent model training.
[0054] In step S30, refer to Figure 1 In step S30, input features are obtained based on the preprocessed historical line loss data.
[0055] As an example, the preprocessed historical line loss data can be screened to obtain the input features. It should be noted that if the lagging feature data is obtained, the lagging feature data and the preprocessed historical line loss data can also be screened to obtain the input features. Specifically, first, a preliminary analysis of the existing input features is performed to evaluate their impact on the target variable. Correlation analysis (such as the Pearson correlation coefficient) can be used to quantify the relationship between the feature and the target variable. The specific formula is: in, Indicates the first of the input characteristics (such as ambient temperature, load rate, etc.) Observations, The first Observations, represents the mean of the input features, such as represents the mean of the target variable; is the Pearson correlation coefficient, which measures the strength and direction of the linear relationship between the input features and the target variable. The value range of is [-1,1]. When , it means that there is a complete positive linear correlation between the input feature and the target variable, that is, as the input feature increases, the target variable increases accordingly, and all data points are on a straight line; when When , it means that the input feature and the target variable are completely negatively linearly correlated, that is, as the input feature increases, the target variable decreases accordingly; when , it means that there is no linear correlation between the input feature and the target variable, but there may be other nonlinear relationships. For example, if the relationship between ambient temperature and line loss rate is calculated , indicating that there is a strong positive linear relationship between the two. When the ambient temperature increases, the line loss rate tends to increase. The target variable usually refers to the variable that you want to predict or study its relationship with other variables. For example, the line loss rate (target variable) is the target variable when studying the relationship between the line loss rate (target variable) and other input features such as ambient temperature and load rate. By calculating the correlation coefficient, you can filter out features that are highly correlated with the target variable.
[0056] As an example, the acquired features are further screened using a feature selection algorithm to obtain input features. The feature selection algorithm can use LASSO regression, random forest, etc. LASSO regression can effectively select the features that have the greatest impact on the model by introducing L1 regularization. Its objective function is: in, is the true value, is the predicted value, is the feature weight, is the regularization parameter. By adjusting , we can control the degree of feature selection. When , LASSO regression becomes an ordinary linear regression. At this time, the regularization term does not work, no feature selection is performed, and all features are retained. Gradually increases, the strength of regularization increases, and some feature weights that have little impact on the target variable will gradually become 0. For example, suppose there is a The corresponding weights are ,when When it increases to a certain extent, if becomes 0, which means that the feature The contribution to the model is small. After the entire model is trained, check the weights corresponding to each feature. , those features whose weights are not 0 are considered to have a greater impact on the model and are the input features for the next step.
[0057] As an example, the line loss prediction method based on the GRU model also includes obtaining seasonal feature data and weather data; the input features also include the seasonal feature data and the weather data. Seasonal features are extracted based on the timestamps of the acquired historical line loss data. For example, features such as "month", "quarter" and "day of the week" can be created to capture the impact of seasonal changes on the target variable. The specific implementation method is: .in, is the timestamp, For the month, For quarter, By introducing these features, the model can better understand seasonal fluctuations.
[0058] As an example, the collected weather data (such as temperature, humidity, precipitation, etc.) is time-aligned with the power data (for example, historical line loss data), and relevant weather features such as "average temperature" and "precipitation" are extracted so that the model can learn the impact of weather changes on power demand. Weather data can include temperature, humidity, precipitation, and interactive data of at least two of the three, such as temperature and humidity data; for example, "temperature" and "humidity" can be combined to form a new feature "temperature and humidity index" to capture more complex relationships. The specific implementation method is: ,in, is the temperature and humidity index, is the temperature, By creating interactive features, we can explore the nonlinear combination relationship between features, enrich feature information, and enable the model to better capture the complex patterns and laws in the data.
[0059] In step S40, refer to Figure 1 In step S40, a GRU model and a LightGBM model are trained based on the input features.
[0060] As an example, the input features may be divided into a training set, a validation set, and a test set.
[0061] As an example, see Figure 2 , the training of the GRU model based on the input features in step S40 may include the following steps: S401~S406.
[0062] S401: Construct a basic GRU model, wherein the basic GRU model includes multiple network layers, and the multiple network layers include: an input layer, a circulation layer, and an output layer.
[0063] S402: Add an Attention layer between the circulation layer and the output layer to obtain a GRU model.
[0064] S403: Use the training set to train the GRU model.
[0065] S404: Use the validation set to evaluate the model performance of the trained GRU model, and adjust the number of network layers and the number of neurons in each network layer based on the evaluated model performance.
[0066] S405: Use grid search method to optimize the hyperparameters of the GRU model.
[0067] S406: Use the test set to evaluate the prediction performance of the GRU model.
[0068] As an example, a basic GRU model is constructed. The basic GRU model includes multiple network layers, including: input layer, loop layer and output layer, and the initial number of layers and neurons are set. Based on the Attention mechanism, an Attention layer is added before the output layer of the basic GRU model to calculate the weight of each time step in the input sequence. A time step refers to a specific position in a sequence, which represents a discrete unit of data in the time or order dimension. It can be understood as a time series (such as a date series) as a unit, such as all feature data on January 1 is 1 time step, and all feature data on January 2 is the second time step. The Attention mechanism can be expressed by the following formula: in, is the query matrix, is the key matrix, is the value matrix, It is the matrix multiplication of the query matrix Q and the transpose of the key matrix K. This result represents the similarity or correlation between the query and the key. is a scaling factor, where is the dimension of the key matrix. Scaling is to prevent the dot product result from being too large when the dimension is large, which will make the gradient of the softmax function too small and affect the training effect. Softmax is an activation function that converts the scaled similarity into a probability distribution, emphasizing those elements with higher similarity. The calculated probability distribution is multiplied by the value matrix V to get the final output. By aggregating information through the Attention mechanism, each element of the output takes into account the importance of different parts of the input sequence.
[0069] As an example, the Attention layer can also use sparse Attention to obtain context dependency information while reducing computational complexity. Sparse Attention can reduce computational complexity by focusing on only some time steps in the sequence, and can reduce the amount of computation by limiting the calculation range of the Attention weight.
[0070] As an example, the Attention layer can adopt a local sparse mode. In the local sparse mode, only the Attention weights between each time step and several adjacent time steps are calculated, that is, for each time step t, only the Attention weights with time step t-1, time step t, and time step t+1 are calculated. This can significantly reduce the amount of calculation while still capturing the local dependencies in the sequence.
[0071] As an example, the Attention layer may also adopt a fixed sparse mode, in which a sparse mode is predefined and the Attention weight is calculated every several time steps. For example, only the Attention of the kth time step may be calculated.
[0072] As an example, the Attention layer can also adopt a learning sparse mode, in which a learning algorithm is used to automatically select important time steps. Specifically, a sparsity constraint can be introduced so that the model automatically selects the most important time steps for Attention calculation during the training process, thereby being able to dynamically adjust the sparsity mode according to the characteristics of the data, thereby improving the flexibility and performance of the model.
[0073] In the above example, compared with the computing time and resource consumption of fully connected Attention when processing sequences of the same length, sparse Attention is more efficient and takes less time. You can choose the appropriate Attention mode according to your actual needs to ensure that the prediction accuracy of the model remains at an acceptable level while ensuring the computational complexity.
[0074] As an example, the GRU model is trained using the training set, the model performance of the trained GRU model is evaluated using the validation set, and the number of layers of the network layer and the number of neurons in each layer of the network layer are adjusted based on the evaluated model performance. Starting from the initial number of layers, the number of layers is gradually increased, different numbers of GRU layers (such as 1 layer, 2 layers, 3 layers, etc.) are tried, the performance of the GRU model on the validation set is observed, and the best number of layers is recorded. In each layer, different numbers of neurons (such as 32, 64, 128, etc.) are tried to find the best model configuration. Increasing the number of layers of the network layer can increase the complexity of the GRU model, but it may also cause overfitting. By observing the performance of the GRU model on the validation set, the best number of layers can be recorded and overfitting can be avoided; an increase in the number of neurons usually improves the learning ability of the model, but it also increases the computational cost. Therefore, the hyperparameters of the GRU model, including learning rate, batch size, regularization parameters, etc., can be further optimized using methods such as grid search or random search. The effects of different hyperparameter combinations are evaluated through cross-validation to find the best configuration.
[0075] As an example, during the training process, the model's loss function and evaluation indicators (such as MSE, MAE, etc.) can be monitored in real time, and the learning rate can be adjusted or training can be stopped early based on the monitoring results to prevent overfitting. The prediction performance of the GRU model can be evaluated through the test set.
[0076] As an example, input features are input into the LightGBM model, and the LightGBM model is trained. LightGBM is able to process structured data using its efficient gradient boosting algorithm. LightGBM uses the gradient boosting algorithm to build models. LightGBM improves training speed through a variety of techniques, such as histogram-based decision tree learning methods, which reduces memory usage and computing time. LightGBM uses a histogram-based splitting method to speed up the training process by discretizing continuous features into histograms. It can directly process category features without the need for one-hot encoding. It also provides a variety of parameters and techniques to reduce overfitting. It also supports distributed training, which can process data in parallel on multiple machines.
[0077] In step S50, refer to Figure 1 In step S50, line loss prediction is performed based on the trained GRU model to obtain a first prediction result.
[0078] As an example, step S40 can train a GRU model, and perform line loss prediction based on the trained GRU model. The prediction result output by the GRU model is the first prediction result.
[0079] Of course, in other examples, different numbers of network layers and neurons can be set to train multiple GRU models, and line loss predictions can be performed separately to obtain multiple GRU prediction results. The first prediction result can be obtained by weighted averaging the multiple GRU prediction results.
[0080] In step S60, refer to Figure 1 In step S60, line loss prediction is performed based on the trained LightGBM model to obtain a second prediction result.
[0081] As an example, the input features can be input into the trained LightGBM model for line loss prediction to obtain the LightGBM prediction results.
[0082] As an example, the prediction result of GRU can also be used as the input of LightGBM model, that is, the input features and the first prediction result are input into the trained LightGBM model for line loss prediction to obtain the second prediction result. This method allows LightGBM to use the time series information captured by the GRU model, thereby improving its prediction ability.
[0083] In step S70, refer to Figure 1 In step S70, a line loss prediction result is obtained based on the first prediction result and the second prediction result.
[0084] In one example, the first prediction result and the second prediction result may be weighted averaged to obtain the line loss prediction result.
[0085] As an example, the weighted average formula is as follows: in, is the first prediction result, is the second prediction result, is the weight of the first prediction result, The weight of the second prediction result, is the line loss prediction result. The weight selection can be determined by cross-validation to find the best combination.
[0086] In another example, the prediction results can also be integrated by stacking models. Specifically, the first prediction result and the second prediction result can be input into a meta-learner for training to obtain the line loss prediction result; more specifically, the first prediction result and the second prediction result are input into a meta-learner (such as a linear regression or other machine learning model) as new features for training. The meta-learner can optimally combine the outputs of the two models to improve the final prediction performance.
[0087] As an example, the GRU model and the LightGBM model are in an integrated learning mode. During the integrated learning process, the performance indicators (such as MSE, MAE, etc.) of the GRU model and the LightGBM model are continuously monitored, and the parameters and weights of the GRU model and the LightGBM model are adjusted according to the evaluation results. Cross-validation can be used to evaluate the effects of different integration strategies to ensure the generalization ability of the model. By weighted fusion of the prediction results of the two models, the fused model can simultaneously utilize the time series learning ability of the GRU model and the nonlinear modeling ability of the LightGBM model, reducing the uncertainty and error of the prediction results of a single model, thereby obtaining more accurate and comprehensive prediction results.
[0088] In some embodiments, after obtaining the line loss prediction result, the prediction error of the GRU model can be monitored, and the parameters of the GRU model can be adjusted when there is an abnormality in the prediction error of the GRU model; the prediction error of the LightGBM model can also be monitored, and the parameters of the LightGBM model can be adjusted when there is an abnormality in the prediction error of the LightGBM model; the prediction error of the GRU model and the prediction error of the LightGBM model can also be monitored at the same time, and the parameters of the GRU model can be adjusted when there is an abnormality in the prediction error of the GRU model, and the parameters of the LightGBM model can be adjusted when there is an abnormality in the prediction error of the LightGBM model.
[0089] As an example, you can set up regular monitoring tasks (such as every hour or every day) to calculate the prediction error. By continuously monitoring the prediction error of the model, you can promptly identify the performance of the model under new data or abnormal conditions and make necessary adjustments. The prediction error of the model is calculated regularly through error indicators. Error indicators can include mean square error (MSE), mean absolute error (MAE), and mean absolute percentage error (MAPE). The error indicator formula is as follows: Among them, MSE is the mean square error. The smaller the MSE, the better the prediction effect of the model. MAE is the average error, which is used to evaluate the average absolute difference between the predicted value and the true value. MAPE is the mean absolute percentage error, which expresses the error in percentage form and is suitable for comparing data of different sizes. is the true value, is the predicted value, is the sample size.
[0090] As an example, during real-time monitoring, an anomaly detection mechanism can be established to identify sudden changes in prediction errors. For example, a threshold can be set, and when the prediction error exceeds a certain preset value, the system automatically triggers an alarm to prompt the user to conduct further analysis. Statistical methods (such as Z-score or IQR) can also be used to detect outliers to ensure the stability of the model.
[0091] As an example, once significant prediction errors or anomalies are detected, timely adjustment of model parameters to adapt to new data features can be achieved by retraining the model or fine-tuning existing model parameters. For example, hyperparameter optimization methods such as grid search or random search can be used to find the best combination of model parameters to improve the prediction performance of the model.
[0092] As an example, a feedback mechanism can be established to feed back real-time monitoring results to the model development team for continuous improvement. Regularly collect the model's prediction results and user feedback, conduct comprehensive evaluation, and iterate and update the model based on the feedback results to ensure continuous optimization of the model. Real-time evaluation can effectively improve the model's adaptability in a dynamic environment and ensure its accuracy and reliability in practical applications.
[0093] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0094] In the line loss prediction method based on the GRU model of the present application, the prediction basis is enriched by acquiring multi-source data, and a variety of factors are comprehensively considered to make the prediction fit the reality; data quality is improved through data preprocessing, and data integrity and reliability are ensured by processing missing values and outliers, and lag features are created to mine time-dependent characteristics, and visualization is used to assist in understanding the data; input features are obtained through screening, data dimensions are reduced, nonlinear relationships are captured, and model generalization and fitting capabilities are improved; GRU models and LightGBM models are constructed and trained to give full play to the advantages of different models, improve prediction accuracy and stability, and enhance generalization and prediction capabilities; the first prediction result and the second prediction result are predicted separately, and the final line loss prediction result is obtained by combining the two to reduce the error of a single model and improve prediction accuracy and reliability. Real-time monitoring and optimization can timely adjust the model to adapt to system changes. Through monitoring of multiple error indicators, timely warning of anomaly detection, adjustment of parameters or retraining, and feedback mechanism to promote continuous improvement, the adaptability of the model can be effectively improved, ensuring its accuracy and reliability in practical applications, and strongly supporting the efficient operation and management of the power system. It can effectively improve the accuracy, stability and model adaptability of line loss prediction, and provide strong support for the operation and management of the power system. This method avoids problems such as information forgetting and insufficient feature selection when processing long time series, which helps power companies to plan and dispatch in advance, effectively reduce line losses, improve the efficiency and economy of power grid operation, adapt to the complex and changeable power environment, and provide strong technical support for the intelligent management and sustainable development of the power system.
[0095] In yet another embodiment, see Figure 3The present application also provides a line loss prediction system based on the GRU model, including: a data acquisition module 10, a preprocessing module 20, an input feature acquisition module 30, a training module 40, a first prediction module 50, a second prediction module 60, and a line loss prediction module 70. Among them, the data acquisition module 10 is used to obtain historical line loss data; the preprocessing module 20 is used to preprocess the historical line loss data; the input feature acquisition module 30 is used to obtain input features based on the preprocessed historical line loss data; the training module 40 is used to train the GRU model and the LightGBM model based on the input features; the first prediction module 50 is used to perform line loss prediction based on the trained GRU model to obtain a first prediction result; the second prediction module 60 is used to perform line loss prediction based on the trained LightGBM model to obtain a second prediction result; the line loss prediction module 70 is used to obtain a line loss prediction result based on the first prediction result and the second prediction result.
[0096] In the above-mentioned line loss prediction system based on the GRU model, multi-source data is obtained through the data acquisition module 10; the preprocessing module 20 improves data quality through operations such as cleaning and normalization, reduces the impact of outliers and missing values, and enhances data availability; the input feature acquisition module 30 integrates multi-source data to obtain rich features, which can reduce irrelevant or redundant features, reduce data dimensions, improve model calculation efficiency, and avoid overfitting problems; the training module 40 trains the GRU model and the LightGBM model, and uses their respective advantages to improve the generalization and learning ability of the prediction model; the line loss prediction results are obtained through the first prediction module 50, the second prediction module 60 and the line loss prediction module 70, which can overcome the limitations of a single model. Through the collaborative work of various modules, it can better adapt to the complex power environment, provide strong support for power system line loss prediction, and help power companies optimize operation management, reduce costs, and improve grid operation efficiency and stability.
[0097] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0098] Although the present application has been disclosed as above with the embodiments, it is not intended to limit the present application. Any person with ordinary knowledge in the technical field can make some changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be determined by the scope of the attached patent application.
Claims
1. A line loss prediction method based on a GRU model, characterized in that: The following steps are involved: Get historical line loss data; Preprocessing the historical line loss data; Obtaining input features based on the preprocessed historical line loss data, wherein the input features include a training set, a validation set, and a test set; Training a GRU model and a LightGBM model based on the input features; the training of the GRU model based on the input features includes: constructing a basic GRU model, the basic GRU model includes multiple network layers, the multiple network layers include: an input layer, a loop layer and an output layer; adding an Attention layer between the loop layer and the output layer to obtain a GRU model; using the training set to train the GRU model; using the validation set to evaluate the model performance of the trained GRU model, and adjusting the number of layers of the network layer and the number of neurons in each layer of the network layer based on the evaluated model performance; using the grid search method to optimize the hyperparameters of the GRU model; using the test set to evaluate the prediction performance of the GRU model; Line loss prediction is performed based on the trained GRU model to obtain the first prediction result; Line loss prediction is performed based on the trained LightGBM model to obtain the second prediction result; A line loss prediction result is obtained based on the first prediction result and the second prediction result.
2. The line loss prediction method based on the GRU model according to claim 1, characterized in that: The preprocessing of the historical line loss data includes: Cleaning the historical line loss data to remove abnormal values in the historical line loss data and fill in missing values in the historical line loss data; The cleaned historical line loss data is normalized.
3. The line loss prediction method based on the GRU model according to claim 1, characterized in that: After acquiring the historical line loss data, the method further includes: creating hysteresis feature data based on the historical line loss data, wherein the hysteresis feature data includes historical line loss data at multiple time points; and the input feature includes at least one of the pre-processed historical line loss data and the hysteresis feature data.
4. The line loss prediction method based on the GRU model according to claim 1, characterized in that: The obtaining of input features based on the preprocessed historical line loss data includes: The preprocessed historical line loss data is screened to obtain the input features.
5. The line loss prediction method based on the GRU model according to claim 1, characterized in that: It also includes acquiring seasonal characteristic data and weather data; the input characteristics also include the seasonal characteristic data and the weather data.
6. The line loss prediction method based on the GRU model according to claim 1, characterized in that: The input features are input into the trained GRU model for line loss prediction to obtain a first prediction result; the input features and the first prediction result are input into the trained LightGBM model for line loss prediction to obtain a second prediction result.
7. The line loss prediction method based on the GRU model according to claim 1, characterized in that: The obtaining a line loss prediction result based on the first prediction result and the second prediction result includes: Performing a weighted average of the first prediction result and the second prediction result to obtain the line loss prediction result; or The first prediction result and the second prediction result are input into a meta-learner for training to obtain the line loss prediction result.
8. The line loss prediction method based on the GRU model according to any one of claims 1 to 7, characterized in that: After obtaining the line loss prediction result based on the first prediction result and the second prediction result, the method further includes: Monitoring the prediction error of the GRU model, and adjusting parameters of the GRU model when the prediction error of the GRU model is abnormal; and / or Monitor the prediction error of the LightGBM model, and adjust the parameters of the LightGBM model when there is an abnormality in the prediction error of the LightGBM model.
9. A line loss prediction system based on a GRU model, characterized in that: The line loss prediction system based on the GRU model is used to execute the line loss prediction method based on the GRU model according to any one of claims 1 to 8, and the line loss prediction system based on the GRU model includes: Data acquisition module, used to obtain historical line loss data; A preprocessing module, used for preprocessing the historical line loss data; An input feature acquisition module, used to obtain input features based on the preprocessed historical line loss data; A training module, used for training a GRU model and a LightGBM model based on the input features; A first prediction module, used for performing line loss prediction based on the trained GRU model to obtain a first prediction result; The second prediction module is used to predict line loss based on the trained LightGBM model to obtain a second prediction result; A line loss prediction module is used to obtain a line loss prediction result based on the first prediction result and the second prediction result.
Citation Information
Patent Citations
Transformer area line loss rate prediction method based on GRU model
CN110598854A
Short-term power consumption load prediction method
CN112215426A
CNN-GRU and SSA-GWO-LightGBM-based air ticket price prediction method
CN114782114A
Intelligent pushing method and system based on intention recognition
CN115809326A
Short-term load prediction method based on GRU-Light GBM model fusion and Bayesian optimization
CN116264388A
Cited By
Flange connection tightness calculation modeling method, calculation method, system, equipment and medium
CN119885497A
Flange Connection Tightness Calculation Modeling Method, Calculation Method, System, Equipment and Medium
CN119885497B