Non-contact electric quantity calculation method and system for overhead line based on random forest algorithm
By adopting a non-contact power calculation method based on the random forest algorithm, the problems of low accuracy in overhead line loss calculation and reliance on manual analysis are solved, achieving high-precision and high-efficiency power calculation.
Patent Information
- Application Number
- CN202411343587.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2044-09-25
AI Technical Summary
In existing technologies, the accuracy of overhead line loss calculation is low and it relies on manual analysis, which makes it impossible to accurately diagnose the real cause and is inefficient.
A contactless power calculation method based on the random forest algorithm is adopted. By acquiring basic power grid data, data preprocessing and topology information processing, a random forest regression model is constructed to achieve high-precision power calculation.
It improves the accuracy and automation of power consumption calculation, reduces manual intervention, and increases work efficiency.
Smart Images

Figure CN119203057B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of power grid operation, in particular to a non-contact power calculation method and system for overhead lines based on a random forest algorithm. BACKGROUND
[0002] Line loss management is an important means for power grid to achieve quality and efficiency. Power is the data basis for line loss calculation and line loss management. In the existing line loss management, the related data of overhead lines in line loss management of line professionals mainly comes from automatic equipment telemetry data. The downstream power data is estimated by automatic equipment telemetry current, which further narrows down the problem range and facilitates on-site personnel to troubleshoot.
[0003] The main problems of the current method are: first, the precision is low, and it is difficult for the automatic equipment to estimate the power accurately, which may lead to calculation error and affect the line loss diagnosis and analysis; second, each automatic equipment lacks power calculation function, which requires a large amount of manual calculation and analysis, and the efficiency is low. SUMMARY
[0004] The purpose of the present application is to provide a non-contact power calculation method and system for overhead lines based on a random forest algorithm, which can more effectively calculate the remote non-contact power of overhead lines.
[0005] In order to achieve the above purpose, the first aspect of the present application provides a non-contact power calculation method for overhead lines based on a random forest algorithm, characterized in that it comprises:
[0006] Obtaining current data of a user;
[0007] Inputting the pre-processed current data into a pre-trained model to output power calculation results;
[0008] The model training step comprises: S1, obtaining power grid basic data; S2, data preprocessing; S3, processing topology information; S4, using a random forest regressor to construct a regression model and training to obtain a pre-established model.
[0009] In the process of processing topology information, the pole number where the user and the automatic switch are located is input into the model for training as line user information. According to the line user information, a multi-layer numerical classification method is used to analyze and process the multi-level branches in the topology information. In the multi-layer numerical classification method, first, a single numerical value in the topology information is analyzed and the depth information of a single topology structure point is calculated. Then, according to the depth information, the numerical values are classified, and the classified same numerical values are taken as a data set corresponding to each depth information. After the topology information is analyzed and converted into numerical features, the model is built and trained.
[0010] S4, model building and training;
[0011] In the model building and training, a regression model is constructed by using a random forest regressor, and the algorithm flow of the regression model construction is:
[0012] S4.1, obtaining a sample data set of labeled power;
[0013] S4.2, sample data normalization;
[0014] S4.3, randomly dividing the sample data set into a training sample set and a test sample set;
[0015] S4.4, training a random forest model by using the training sample set data to obtain a trained random forest model;
[0016] The trained random forest model, combined with a grid search and a cross-validation strategy, establishes optimal model parameters of a cross-validation grid optimization random forest prediction model, and the algorithm flow of the cross-validation grid is:
[0017] S4.4.1, setting initial parameters;
[0018] S4.4.2, establishing a hyperparameter combination grid;
[0019] S4.4.3, 5-fold cross-validation;
[0020] S4.4.4, using the coefficient of determination R 2 Evaluate the performance of the regression model;
[0021] S4.4.5, find the best model hyperparameter combination.
[0022] S4.5, verifying the calculation performance of the trained random forest model by using the test sample set to complete the training of the model
[0023] The second aspect of the present application proposes a non-contact power calculation system for overhead lines based on a random forest algorithm, comprising:
[0024] An acquisition module is configured to acquire current data of a user;
[0025] A power calculation module is configured to input the preprocessed current data into a pre-established model to obtain a power calculation result;
[0026] The model training step includes: S1, obtaining power grid basic data; S2, data preprocessing; S3, processing topology information; S4, constructing a regression model by using a random forest regressor and training to obtain a pre-established model.
[0027] In view of the defects and deficiencies in the prior art, the non-contact power calculation method and system for overhead lines based on the random forest algorithm realize multiple advantages through the following specific improvements:
[0028] 1. High-precision acquisition:
[0029] The automatic equipment telemetry data in the prior art is low in precision, and it is difficult to meet the power calculation requirements. The present application realizes high-precision acquisition of power data on the basis of original current data by introducing historical data analysis and advanced data processing algorithms, and ensures the accuracy and reliability of power calculation.
[0030] 2. System construction and data analysis function:
[0031] The prior art lacks effective power analysis and calculation functions, and relies on manual calculation, which is low in efficiency. The present application integrates data acquisition, processing and analysis into one system, and can automatically complete power data analysis and calculation, greatly improving work efficiency and reducing manual intervention. BRIEF DESCRIPTION OF DRAWINGS
[0032] The drawings accompanying the specification of the present application form part of the present application and serve to provide further understanding of the present application, and the illustrative embodiments of the present application and their descriptions serve to explain the present application, and do not constitute an improper limitation on the present application. In the drawings:
[0033] Figure 1 The model training process schematic diagram provided by the embodiment of the present application;
[0034] Figure 2 The model algorithm schematic diagram provided by the embodiment of the present application;
[0035] Figure 3 The power calculation process schematic diagram provided by the embodiment of the present application. DETAILED DESCRIPTION
[0036] The present application will be described in detail below with reference to the drawings and in combination with the embodiments. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.
[0037] The following detailed description is exemplary and is intended to provide further detailed description of the present application. Unless otherwise specified, all technical terms used in the present application have the same meaning as generally understood by those skilled in the art to which the present application belongs. The terms used in the present application are only for the purpose of describing the specific embodiments, and are not intended to limit the exemplary embodiments according to the present application.
[0038] The first aspect of the present embodiment provides a non-contact power calculation method for overhead lines based on the random forest algorithm, please refer to Figure 1 ,Figure 1 A model training flowchart provided by an embodiment of the present application, the method comprising the following steps: S1, obtaining power grid basic data;
[0039] The power grid basic data comprises marketing management data, metering automation data, distribution network automation data and dispatching automation system data. That is, the power grid basic data is sample data for building the model.
[0040] Specifically, the power grid basic data can be obtained through data integration. The marketing management data, i.e. marketing system file data, comprises but is not limited to basic information of devices such as substations, lines, transformers, user basic file information, running electric energy meters, terminal devices, transformers and business data such as meter replacement; the metering automation data comprises but is not limited to metering automation meter codes, loads, currents, voltages, running conditions, alarm information and other collected data; the distribution network automation data comprises but is not limited to distribution network device and user topology data, and topology change data caused by load cutting and power transfer; the dispatching automation system data comprises but is not limited to main network device topology data and switch closing and opening information.
[0041] S2, data preprocessing;
[0042] This step comprises calculating the root mean square (RMS) of current data, calculating current data statistical indicators and logarithmic transformation of the statistical indicators. In order to facilitate data processing, compress data volume and also extract features from the current data.
[0043] Calculating the root mean square (RMS) of current data: calculating the RMS value is a common method for measuring the size of an electrical signal, especially in alternating current (AC). The RMS value is the square root of the average of the squares of a set of values. In electrical signals, this can be used to measure the effective value of current or voltage. The specific calculation method is as follows: multiply the user or area three-phase current by a specified multiple, i.e. the transformer ratio, in order to adjust the current measurement value to the actual current size. Square the sum of the true values of the user or area three-phase current and divide by three, and finally take the square root to obtain the RMS value. In practical applications, the RMS value can be used to evaluate the stability and variability of the current, because it can effectively express the average energy of the periodically varying current. This step can reduce the amount of current data and improve the calculation efficiency.
[0044] For three-phase currents that are not strictly symmetrical, the total RMS value needs to be calculated for each phase RMS value and then combined. The final formula is:
[0045]
[0046] Compute current data statistics: Use the describe() method to generate a statistical description of the RMS values, which includes calculating the minimum, maximum, mean, standard deviation, first quartile, median, third quartile, etc. This provides a quick overview of the distribution of the data, facilitating the analysis of current changes and stability, and the calculation of power using current.
[0047] Logarithmic transformation of statistical indicators: In the field of data processing and machine learning, logarithmic transformation of data is a common preprocessing step. This transformation is usually used to reduce the skewness of data, making it closer to a normal distribution, or to reduce the range of differences between data, facilitating analysis or model training. The purpose of logarithmic transformation: Reduce skewness: Many real-world data distributions are skewed, i.e., data is skewed to one side. Logarithmic transformation can help reduce the skewness of data, making it more symmetrically distributed; Handle outliers: Logarithmic transformation can reduce the impact of extreme values on overall analysis, as it reduces the relative difference between larger and smaller values; Linear relationship: In some cases, logarithmic transformation can help linearize the relationship between variables, making linear models (such as linear regression) more effective in fitting data.
[0048] S3, processing topology information;
[0049] Considering that the farther away from the gate, the more the voltage will drop, and the relationship between current and power will be less linear, and according to the topology information of the automatic switch, it can also know the connected users behind it, which is convenient for calculating the power of the automatic switch, therefore, the topology information of the line user is also input into the model to reflect this information.
[0050] In the present application, the user and the automatic switch are located in the pole number as the topology information of the user and the automatic switch input into the model for training, considering that some users are located on the main road, and some are located on the branch, while some lines have multiple levels of branches, and now multiple numerical values are used to reflect this situation, so that the topology information of the users on the multiple levels of branches can be effectively input into the model. By analyzing the single numerical value in the topology information, the depth information of the single topology structure point is calculated, and then the numerical value is classified according to the depth information, and the same type of numerical value after classification is used as a data set corresponding to each depth information.
[0051] Part of the user topology information processing result is shown in Table 1:
[0052] Table 1
[0053] User name Topology information User 1 25,1 User 2 31,6,1 User 3 28,3,3,1 User 4 28,14,10 User 5 28,3,3,4 User 6 28,3,4,1 User 7 28,14,4,1 User 8 28,14,4,3 User 9 31,15,4 User 10 31,15,12
[0054] According to Table 1, user 1 is located at No. 1 pole on the No. 25 pole branch of the main line, user 2 is located at No. 1 pole on the No. 6 pole branch of the No. 31 pole branch of the main line, and so on. The topology information of the users is represented by this multi-layer numerical method.
[0055] During the training process, the topology information is parsed and converted into numerical features for use in the machine learning model. The specific processing steps are as follows:
[0056] First, the comma-separated numerical string in the Tuopu column is converted into a numerical list.
[0057] Next, the length of each list (Tuopu_count) is calculated to reflect the complexity of the topology structure, which helps the model evaluate the impact of the number of nodes in the topology structure on energy consumption.
[0058] At the same time, the sum of the numerical values in the list (Tuopu_sum) is calculated, which represents the cumulative characteristics of the topology structure and can reveal the possible impact of the overall electrical properties of the topology on energy consumption.
[0059] Finally, the original Tuopu column and the intermediate generated list column are deleted, and only these extracted numerical features are retained. These features can help the model better understand and utilize the impact of the topology structure on energy consumption, improving the accuracy of the calculation.
[0060] S4, model building and training;
[0061] The model building and training includes model training, model validation and model saving. The model input data of this example includes the current data of the power distribution network users, the current data of the automatic switches, the topology structure information of the circuit, and the electric quantity information of the gateway; the output data is the electric quantity corresponding to the current flowing through a certain point of the power distribution network in a day.
[0062] The specific parameters are shown in the following table:
[0063] Table 2
[0064] Serial number 1 2 3 4 5 6 7 8 9 10 Parameter Mean Std Min 25% 50% 75% Max Tuopu Total Energy
[0065] As shown in Table 2, the first seven parameters are the minimum value, maximum value, mean value, standard deviation, first quartile, median, third quartile, and maximum value of the current data in a day, which are statistical indicators of the current data and can reflect more detailed information of the current data of the power distribution network users in a day; the eighth parameter 'Tuopu' is the topology information of the user or automatic switch; the ninth parameter 'Total' is the gateway electric quantity information of the line on which the user or automatic switch is located, and the tenth parameter 'Energy' is the target value of the model in this example: the electric quantity corresponding to the current flowing through the user or automatic switch in a day.
[0066] During the training process, the construction and training of the model involves creating a comprehensive machine learning pipeline that includes data preprocessing, feature selection, and regression analysis.
[0067] Firstly, through standardization processing and feature selection based on statistical tests, the data input into the model is ensured to have proper format and quality.
[0068] Subsequently, a regression model is constructed using a random forest regressor, combined with grid search and cross-validation strategies to establish the optimal model parameters for the cross-validation grid search random forest prediction model. This process not only improves the prediction accuracy of the model, but also enhances its generalization ability when facing unseen data.
[0069] Finally, the finely tuned model is trained on the entire dataset to fully capture and learn the potential relationships and patterns in the data, and the completed model is saved to a designated path to support and serve subsequent application scenarios. Through this series of detailed and rigorous steps, the efficiency and reliability of the model in practical applications are ensured.
[0070] Please refer to Figure 2 , Figure 2 The algorithm flow for constructing a regression model using a random forest regressor is shown, including:
[0071] S4.1 Obtain a sample dataset of labeled power consumption;
[0072] S4.2 Normalize the sample data;
[0073] Ensure that all data features have been properly adjusted and standardized before data segmentation and model training. This can effectively improve the effectiveness of model training and the final calculation accuracy;
[0074] S4.3 Randomly divide the sample dataset into training sample set and test sample set;
[0075] In the present invention, 80% of the sample dataset is used as the training sample set and 20% as the test sample set. This segmentation helps to verify the effectiveness and generalization ability of the model in subsequent model training;
[0076] S4.4 Train the random forest model using the training sample set data to obtain the trained random forest model;
[0077] Among them, the random forest constructs multiple decision trees to handle classification and regression tasks, and specifically establishes a cross-validation grid search random forest prediction model.
[0078] At the beginning of the algorithm, the number of trees to be generated is determined. For each tree, first, a sample is selected from the training dataset by random sampling with replacement, also known as bootstrap sampling, and then at each decision point, a subset of features is randomly selected.
[0079] For each tree node, m features are randomly selected, and the optimal split is calculated, usually based on maximum information gain or Gini impurity:
[0080]
[0081] where IG is the information gain, D p is the dataset of the parent node, D left and D right are the datasets of the left and right child nodes after splitting, N, N left and N right are the sample sizes of the parent node and the two child nodes, respectively.
[0082] For the selection of random features, at each split, instead of choosing the best split feature from all features, a subset is randomly selected, which helps to improve the diversity of the forest.
[0083] Each tree is built independently, and according to the selected sample and features, the data is recursively split until a predetermined stopping condition is reached, such as the tree reaching a maximum depth or the number of samples under a node being less than a minimum split limit.
[0084] For this regression problem in this embodiment, in the prediction stage, each tree predicts a numerical value, and the final prediction result is the average of all tree prediction values:
[0085]
[0086] Random forests reduce the risk of overfitting and improve the model's generalization ability on unseen data in this way. The specific steps of the cross-validation grid search random forest prediction model are as follows:
[0087] S4.4.1 Set initial parameters;
[0088] S4.4.2 Establish a grid of hyperparameter combinations;
[0089] S4.4.3 5-fold cross-validation;
[0090] In the present application, the data set is divided 5 times in total, and then 5 training and validation are performed, in each training, 4 subsets are selected as the training sample set, and the remaining 1 subset is selected as the validation set. In each validation, the model is trained and evaluated, so a total of 5 independent training and evaluation are performed. After recording the performance indicators of each training and validation, the average value of the 5 validation results is calculated as the final performance evaluation indicator of the model. Through this method, 5-fold cross-validation not only provides the performance of the model on different data sets, but also reduces the bias caused by uneven data division, ensuring that the evaluation of the model is more stable and reliable.
[0091] S4.4.4 Adopting the coefficient of determination R 2 The performance of the regression model is evaluated.
[0092] The coefficient of determination R 2 The coefficient of determination R represents the fitting degree of the model to the data, that is, the proportion of the variance explained by the model to the total variance. Its value ranges from 0 to 1, and the closer the value is to 1, the stronger the model's ability to explain the data. The calculation formula of the coefficient of determination is as follows:
[0093]
[0094] S4.4.5 Finding the best model hyperparameter combination.
[0095] Finding the best model hyperparameter combination is an important step to improve the performance of the random forest model. First, the hyperparameters to be adjusted and their value ranges need to be defined. In the present application, the number of decision trees (n_estimators) is set to several values between 100 and 500, the maximum depth of the tree (max_depth) is selected between 10 and 50, the minimum number of samples required for node splitting (min_samples_split) and the minimum number of samples required for leaf nodes (min_samples_leaf) are selected as 2, 5, 10 and 1, 2, 4 respectively, and the maximum number of features (max_features) is selected as 'auto','sqrt', 'log2', etc. Then, the hyperparameter search method is selected, and the present application adopts the grid search method. The grid search finds the best parameters by traversing all possible hyperparameter combinations, although the calculation cost is high, but it can find the global optimal solution.
[0096] S4.5 The calculation performance of the trained random forest model is verified by using the test sample set to complete the training of the model. DETAILED EMBODIMENT:
[0098] Please refer to Figure 3 , Figure 3 The present application provides a specific embodiment of a random forest algorithm-based non-contact power calculation for overhead lines.
[0099] A1, Load parameters:
[0100] First, the system will load relevant parameters, including the path of the model, the path of the input data, preprocessing parameters, etc. The main purpose of parameter loading is to provide necessary information and settings for subsequent steps to ensure smooth progress. These parameters are the basis for subsequent steps.
[0101] Model path: Specifies the location of the trained model file.
[0102] Data path: Specifies the location of the input data file.
[0103] Preprocessing parameters: Including normalization parameters, missing value processing methods, etc.
[0104] The specific parameter input format is as follows:
[0105] mode = 1 # 0 for automatic switch, 1 for user;
[0106] model_path ='model path' # input model path;
[0107] file_path = 'current excel table path' # input exported current excel table path;
[0108] tuopu = '10,4' # input topology information, separated by commas;
[0109] # If it is a user, additional input the following parameters;
[0110] multiplier = 600 # input transformer ratio to restore the true current;
[0111] total = 10456.1 # key point power information.
[0112] A2, Determine the category:
[0113] The system will determine the type of data to be processed according to the loaded parameters. If it is user data (Model = 1), it will enter the user power calculation process; if it is an automatic switch data (Model = 0), it will enter the automatic switch power calculation process.
[0114] A3, User power calculation, the specific process is:
[0115] A3.1, Load trained model:
[0116] The system will load the previously trained user power calculation model. These models have been trained and can be calculated according to the input data.
[0117] A3.2, Load current data and calculate RMS statistical indicators:
[0118] The system loads the user's current data and calculates the RMS (Root Mean Square) statistical indicators of the data as one of the input features of the model.
[0119] For three-phase current not strictly symmetrical, the total RMS value needs to calculate the RMS value of each phase respectively, and then combine. The final formula is:
[0120]
[0121] The example user statistical indicators calculated by the algorithm are shown in the following table;
[0122] Table three
[0123] Serial number 1 2 3 4 5 6 7 Statistical index Mean Std Min 25% 50% 75% Max Calculated value 52.913 16.833 29.688 38.182 48.659 64.918 94.86
[0124] Processing topology information will be parsed from Tuopu string to get the derived data of topology information: the number of topology structure (Tuopu_count) and the sum of all topology values (Tuopu_sum).
[0125] The example user topology information calculated by the algorithm is shown in the following table;
[0126] Table four
[0127] Data Input information Topology data 1 Topology data 2 Data name Tuopu Tuopu_count Tuopu_sum Value 10,4 2 14.0
[0128] A3.3, Build input DataFrame:
[0129] Organize the current data and its calculated RMS statistical indicators into a DataFrame, which is a high-efficiency data structure for data processing and model input.
[0130] The data information obtained above constitutes the complete input feature set of the model.
[0131] The complete input feature set is shown in the following table:
[0132] Table five
[0133] Serial number 1 2 3 4 5 6 7 8 9 10 Parameter Mean Std Min 25% 50% 75% Max Total Tuopu_count Tuopu_sum Value 52.9 16.8 29.7 38.1 48.7 64.9 94.8 10456.1 2 14.0
[0134] A3.4, Preprocess data:
[0135] Preprocess the data in DataFrame, including missing value processing, standardization and other steps, to ensure that the data meets the input requirements of the model. Data preprocessing is to ensure that the data meets the input requirements of the model and improve the calculation accuracy of the model. The standardization formula is as follows:
[0136]
[0137] A3.5, Processing topology information:
[0138] When calculating the electricity consumption using the trained model, the topology information (Tuopu column) is processed as follows: First, the comma-separated numerical string in the Tuopu column is converted into a numerical list. Then, the length of each list (Tuopu_count) is calculated from these lists to reflect the complexity of the topology structure, which helps the model evaluate how the number of nodes in the topology structure affects energy consumption. At the same time, the sum of the values in the list (Tuopu_sum) is calculated, which represents the cumulative characteristics of the topology structure and can reveal the possible impact of the overall electrical properties of the topology on energy consumption.
[0139] A3.6, Adding topology information to DataFrame:
[0140] The processed topology features are then integrated into the input feature set of the model, so that the model can use this information for accurate energy consumption prediction. In this way, the model can more effectively understand and utilize the information of the topology structure, improving the accuracy of the calculation of electricity consumption.
[0141] A3.7, Calculation:
[0142] Using the selected model to calculate the preprocessed data, the user's electricity consumption results are output.
[0143] A3', Automated switch electricity calculation process:
[0144] A3'.1, Load current parameters:
[0145] The system will load the current parameters related to the automation switch.
[0146] A3'.2, Calculate statistical indicators:
[0147] According to the loaded current parameters, calculate the relevant statistical indicators, which will be used as input features of the model.
[0148] A3'.3, Process topology information:
[0149] Process the topology information of the automation switch in the same way as the user and area topology information, so that the model for calculating the electricity consumption of the automation switch can be established based on the model for calculating the electricity consumption of the user.
[0150] A3'.4, Establish automation switch calculation model:
[0151] In the process of establishing the automatic switch power calculation model, first, based on the trained user power calculation model, the relationship between user voltage drop and power grid topology is analyzed using big data analysis and machine learning algorithms. By mining this relationship, a voltage drop model is constructed, which can calculate the voltage value of the automatic switch using the topology information of the automatic switch. Further, combined with the current information of the automatic switch and the established voltage drop model, the power consumption of the automatic switch can be calculated more accurately.
[0152] A3′.5, calculate:
[0153] The pre-processed data is calculated using the voltage drop model to obtain the power of the automatic switch.
[0154] A4, output the calculation result:
[0155] The calculation result is output and displayed to the user, and a complete example is shown to verify the user data with accurate power data. The processed feature set is input into the loaded model for calculation, and the model outputs the calculated user power consumption value. The model output result (unit: kilowatt-hour) is Result: 430.862.
[0156] The calculation result of this example is shown:
[0157] Table six
[0158]
[0159]
[0160] Prediction result analysis:
[0161] The model calculates the users and areas on different lines in detail, and the results show that the model achieves high calculation accuracy on each line. Whether the user has a large power base or a small power base, the model can provide accurate calculation results and exhibit good applicability.
[0162] The second aspect of this embodiment proposes an overhead line-oriented non-contact power calculation method based on the random forest algorithm, which includes:
[0163] Obtain the current data of the user;
[0164] After preprocessing the current data, input it into the pre-trained model to output the power calculation result;
[0165] The model training step includes: S1, obtaining power grid basic data; S2, data preprocessing; S3, processing topology information; S4, constructing a regression model by using a random forest regressor and training to obtain a pre-established model.
[0166] In an embodiment, the power grid basic data includes marketing management data, metering automation data, distribution network automation data, and dispatching automation system data; in the processing of topology information, the pole number where the user and the automation switch are located is taken as line user information input into the model for training.
[0167] Specifically, the power grid basic data can be obtained through data integration. The marketing management data, i.e., marketing system file data, includes but is not limited to basic information of devices such as substations, lines, transformers, user basic file information, running electric energy meters, terminal devices, transformers, and business data such as meter replacement; the metering automation data includes but is not limited to metering automation meter codes, loads, currents, voltages, running conditions, and alarm information; the distribution network automation data includes but is not limited to distribution network device and user topology data, and topology change data caused by load cutting and power supply switching; the dispatching automation system data includes but is not limited to main network device topology data, and switch closing and opening information.
[0168] In an embodiment, S2, data preprocessing: this step includes calculating the root mean square (RMS) of current data, calculating current data statistical indicators, and logarithmic transformation of the statistical indicators. In order to facilitate data processing, compress data volume, and also extract features from current data.
[0169] Calculating the root mean square (RMS) of current data: calculating the RMS value is a common method for measuring the size of an electrical signal, especially in alternating current (AC). The RMS value is the square root of the average of the squares of a set of values. In electrical signals, this can be used to measure the effective value of current or voltage. The specific calculation method is: multiply the user or area three-phase current by a specified multiple, i.e., the transformer ratio, which is to adjust the current measurement value to the actual current size. Square the sum of the true values of the user or area three-phase current and divide by three, and finally take the square root to obtain the RMS value. In practical applications, the RMS value can be used to evaluate the stability and variability of the current, because it can effectively express the average energy of the periodic varying current. This step can reduce the amount of current data and improve the calculation efficiency.
[0170] For three-phase currents that are not strictly symmetrical, the total RMS value needs to be calculated for each phase RMS value and then combined. The final formula is:
[0171]
[0172] Compute current data statistics: Use the describe() method to generate a statistical description of the RMS values, which includes calculating the minimum, maximum, mean, standard deviation, first quartile, median, third quartile, etc. This provides a quick overview of the distribution of the data, facilitating the analysis of current changes and stability, and the calculation of power using current.
[0173] Log transformation of statistical indicators: In the field of data processing and machine learning, log transformation of data is a common preprocessing step. This transformation is usually used to reduce the skewness of data, make it closer to normal distribution, or reduce the range of differences between data, facilitating analysis or model training. The purpose of log transformation: Reduce skewness: Many real-world data distributions are skewed, i.e. data is skewed to one side. Log transformation can help reduce the skewness of data, making it more symmetrically distributed; Handle outliers: Log transformation can reduce the impact of outliers on overall analysis, as it reduces the relative difference between larger and smaller values; Linear relationship: In some cases, log transformation can help linearize the relationship between variables, making linear models (such as linear regression) more effective in fitting data.
[0174] In a specific embodiment, step S3, processing topology information:
[0175] Considering that the farther away from the gate, the more the voltage will drop, the relationship between current and power will be less linear, and according to the topology information of the automatic switch, it can also know the connected users behind it, which is convenient for calculating the power of the automatic switch, therefore, the topology information of the line user is also input into the model to reflect this information.
[0176] In the present application, the user and the automatic switch are located in the pole number as the topology information of the user and the automatic switch input into the model for training, considering that some users are located on the main road, some are located on the branch, and some lines have multiple levels of branches, the present application uses multiple numerical values to reflect this situation, so that the topology information of the users on the multiple levels of branches can be effectively input into the model. By analyzing the single numerical value in the topology information, the depth information of the single topology structure point is calculated, and then the numerical value is classified according to the depth information, and the same type of numerical value after classification is used as a data set corresponding to each depth information.
[0177] Part of the user topology information processing result is shown in Table 1:
[0178] Table 1
[0179] User name Topology information User 1 25,1 User 2 31,6,1 User 3 28,3,3,1 User 4 28,14,10 User 5 28,3,3,4 User 6 28,3,4,1 User 7 28,14,4,1 User 8 28,14,4,3 User 9 31,15,4 User 10 31,15,12
[0180] According to Table 1, user 1 is located at No. 1 pole of the main line 25 pole branch, user 2 is located at No. 1 pole of the branch of No. 6 pole of the main line 31 pole branch, and so on. The multi-level numerical method is used to represent the topology information of the user.
[0181] During the training process, the topology information is parsed and converted into numerical features for use in the machine learning model. The specific processing steps are as follows:
[0182] First, the comma-separated numerical string in the Tuopu column is converted into a numerical list.
[0183] Next, the length of each list (Tuopu_count) is calculated to reflect the complexity of the topology structure, which helps the model evaluate the impact of the number of nodes in the topology structure on energy consumption.
[0184] At the same time, the sum of the numerical values in the list (Tuopu_sum) is calculated, which represents the cumulative characteristics of the topology structure and can reveal the possible impact of the overall electrical properties of the topology on energy consumption.
[0185] Finally, the original Tuopu column and the intermediate generated list column are deleted, and only these extracted numerical features are retained. These features can help the model better understand and utilize the impact of the topology structure on energy consumption, improving the accuracy of the calculation.
[0186] In one embodiment, according to the line user information, a multi-level numerical classification method is established to parse and process the multi-level branches in the topology information.
[0187] In one embodiment, in the multi-level numerical classification method, first, the single numerical value in the topology information is parsed, and the depth information of the single topology structure point is calculated. Then, according to the depth information, the numerical values are classified, and the classified numerical values of the same type are taken as a data set corresponding to each depth information.
[0188] In one embodiment, after the topology information is parsed and converted into numerical features, the model is built and trained.
[0189] In one embodiment, after the current data is preprocessed, the current data is input into the pre-established model to obtain the power calculation result. The specific steps include:
[0190] Calculate the RMS statistical index of the current data as one of the input features of the model;
[0191] Organize the current data and the RMS statistical index into a DataFrame, and form a complete input feature set of the model with the obtained data information;
[0192] Preprocessing the data in the DataFrame, including missing value processing and standardization;
[0193] When calculating the power using the trained model, the topology information is processed as follows: first, the comma-separated numerical string in the Tuopu column is converted into a numerical list; then, the length of each list is calculated to reflect the complexity of the topology structure; at the same time, the sum of the numerical values in the list is calculated;
[0194] After parsing and converting the topology information into numerical features, it is added to the DataFrame;
[0195] The DataFrame is input into the pre-trained model, and the power calculation result is output.
[0196] In a specific embodiment, the algorithm flow of the regression model construction is as follows:
[0197] S4.1 Obtain a sample data set with labeled power;
[0198] S4.2 Sample data normalization;
[0199] S4.3 Randomly divide the sample data set into a training sample set and a test sample set;
[0200] S4.4 Train the random forest model using the training sample set data to obtain a trained random forest model;
[0201] In particular, the random forest model is used to process classification and regression tasks by constructing multiple decision trees, and a cross-validation grid search random forest prediction model is established.
[0202] At the beginning of the algorithm, the number of trees to be generated is determined. For each tree, first, samples are selected from the training data set by random sampling with replacement, i.e., the bootstrap sampling method, and then a part of the features is randomly selected at each decision point.
[0203] For each tree node, m features are randomly selected, and the optimal splitting method is calculated, usually based on the maximum information gain (Information Gain) or Gini Impurity (Gini Impurity):
[0204]
[0205] where IG is the information gain, D p is the parent node data set, D left and D rjght are the data sets of the left and right child nodes after splitting, N, N left and N right are the sample sizes of the parent node and the two child nodes.
[0206] For selecting random features, at each split, instead of selecting the best split feature from all features, a random subset is selected, which helps to improve the diversity of the forest.
[0207] Each tree is built independently, based on the selected samples and features, recursively split the data until a pre-defined stopping condition is reached, such as the tree reaches a maximum depth or the number of samples under a node is less than a minimum split limit.
[0208] For this regression problem in this embodiment, in the prediction phase, each tree predicts a numerical value, and the final prediction result is the average of all tree prediction values:
[0209]
[0210] S4.5. Verify the calculation performance of the trained random forest model using the test sample set to complete the training of the model.
[0211] In a specific embodiment, the training of the random forest model in S4.4 combines the grid search and cross-validation strategy to establish the optimal model parameters of the cross-validation grid search random forest prediction model.
[0212] In a specific embodiment, the algorithm flow of the cross-validation grid is as follows:
[0213] S4.4.1 Set initial parameters;
[0214] S4.4.2 Establish a hyperparameter combination grid;
[0215] S4.4.3 5-fold cross-validation;
[0216] In a specific embodiment, the present application will divide the data set 5 times in total, and then perform 5 times of training and verification. In each training, 4 subsets are selected as the training sample set, and the remaining 1 subset is selected as the verification set. In each verification, the model is trained and evaluated, so a total of 5 independent training and evaluation are performed. After recording the performance indicators of each training and verification, the average value of the 5 verification results is calculated as the final performance evaluation indicator of the model. Through this method, 5-fold cross-validation not only provides the performance of the model on different data sets, but also reduces the bias caused by uneven data division, ensuring that the evaluation of the model is more stable and reliable.
[0217] S4.4.4 Use the coefficient of determination R 2 Evaluate the performance of the regression model;
[0218] Coefficient of determination R 2R-squared, denoted as R2, represents the degree of fit of the model to the data, that is, the proportion of the total variance explained by the model. Its value ranges from 0 to 1, and the closer the value is to 1, the stronger the model's ability to explain the data. The formula for calculating the coefficient of determination is as follows:
[0219]
[0220] S4.4.5 Finding the best model hyperparameter combination.
[0221] Finding the best model hyperparameter combination is an important step to improve the performance of the random forest model. First, the hyperparameters to be adjusted and their value ranges need to be defined. In this invention, the number of decision trees (n_estimators) is set to several values between 100 and 500, the maximum depth of the tree (max_depth) is selected between 10 and 50, the minimum number of samples required for node splitting (min_samples_split) and the minimum number of samples required for leaf nodes (min_samples_leaf) are selected as 2, 5, 10 and 1, 2, 4 respectively, and the maximum number of features (max_features) is selected as 'auto','sqrt', 'log2', etc. Then, the hyperparameter search method is selected. This invention uses the grid search method. Grid search finds the best parameters by traversing all possible combinations of hyperparameters, although the computational cost is high, but it can find the global optimal solution.
[0222] The third aspect of this embodiment proposes an overhead line-oriented non-contact power calculation system based on the random forest algorithm, which includes:
[0223] The acquisition module is configured to acquire current data of a user.
[0224] The power calculation module is configured to input the preprocessed current data into a pre-established model to obtain a power calculation result output and display it to the user.
[0225] The model training step includes: S1, acquiring power grid basic data; S2, data preprocessing; S3, processing topology information; S4, using a random forest regressor to construct a regression model and train it to obtain a pre-established model.
[0226] From the technical common sense, the present invention can be realized by other embodiments without departing from the spirit or essential characteristics thereof. Therefore, the above disclosed embodiments are only examples and are not the only ones. All changes within the scope of the present invention or within the scope equivalent to the present invention are included in the present invention.
[0227] Those skilled in the art will appreciate that embodiments of the application can be devised for a method, a system, or a computer program product. Accordingly, the present application can be embodied in the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer readable program code.
[0228] The present application is described in reference to the flowchart and / or block diagrams of the method, apparatus (system) and computer program product according to embodiments of the application. It will be understood that each block of the flowchart and / or block diagrams, and combinations of blocks in the flowchart and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processing device or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.
[0229] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.
[0230] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.
[0231] Finally, it should be noted that the above-mentioned embodiments are merely intended for describing the technical solutions of the present application, but not for limiting it. Although the present application is described in detail with reference to the above embodiments, those skilled in the field should understand that the specific embodiments of the present application can be modified or replaced equivalently without departing from the spirit and scope of the present application, and any modification or equivalent replacement without departing from the spirit and scope of the present application should be covered in the protection scope of the claims of the present application.
Claims
1. An overhead line-oriented non-contact power calculation method based on a random forest algorithm, characterized by, The method comprises the following steps: obtaining current data of a user; inputting the preprocessed current data into a pre-trained model to output an electricity calculation result; wherein the model training step comprises: S1, obtaining power grid basic data; S2, data preprocessing; S3, processing topology information; S4, constructing a regression model using a random forest regressor and training to obtain a pre-established model; the power grid basic data comprises marketing management data, metering automation data, distribution network automation data and dispatching automation system data; in the process of processing topology information, the pole number where the user and the automation switch are located is taken as line user information and input into the model for training; the step of inputting the preprocessed current data into the pre-established model to obtain the electricity calculation result specifically comprises: calculating the RMS statistical index of the current data as one of the input features of the model; arranging the current data and the RMS statistical index into a DataFrame, and constructing the obtained data information into a complete input feature set of the model; preprocessing the data in the DataFrame, including missing value processing and standardization; when the trained model is used to calculate the electricity, the topology information is processed as follows: firstly, the comma-separated numerical string in the Tuopu column is converted into a numerical list; then, the length of each list is calculated to reflect the complexity of the topology structure; at the same time, the sum of the numerical values in the list is calculated; the topology information is parsed and converted into numerical features and added to the DataFrame; the DataFrame is input into the pre-trained model to output the electricity calculation result.
2. The non-contact power calculation method for overhead lines based on random forest algorithm according to claim 1, characterized in that, According to the line user information, a multi-layer numerical classification method is established to analyze and process the multi-level branches in the topology information. 3.The overhead line oriented non-contact power calculation method based on random forest algorithm according to claim 2, characterized in that, In the multi-layer numerical classification method, firstly, a single numerical value in the topology information is analyzed, and the depth information of a single topology structure point is calculated, and then the numerical values are classified according to the depth information, and the classified numerical values of the same type are taken as a data set corresponding to each depth information.
4. The non-contact power calculation method for overhead lines based on random forest algorithm according to claim 1, characterized in that, After the topology information is parsed and converted into numerical features, the model is built and trained.
5. The non-contact power calculation method for overhead lines based on random forest algorithm according to claim 1, characterized in that, The algorithm flow of the regression model construction is as follows: S4.1 obtaining a sample data set of labeled electricity; S4.2 sample data normalization; S4.3 randomly dividing the sample data set into a training sample set and a test sample set; S4.4 training the random forest model using the training sample set data to obtain a trained random forest model; S4.5 verifying the calculation performance of the trained random forest model using the test sample set to complete the training of the model.
6. The non-contact power calculation method for overhead lines based on random forest algorithm according to claim 5, wherein, In S4.4, the training of the random forest model combines the grid search and cross-validation strategies to establish the optimal model parameter of the cross-validation grid search random forest prediction model.
7. The non-contact power calculation method for overhead lines based on random forest algorithm according to claim 6, characterized in that, The algorithm flow of the cross-validation grid is as follows: S4.4.1 setting initial parameters; S4.4.2 establishing a hyperparameter combination grid; S4.4.3 5-fold cross-validation; S4.4.4 Adopting the coefficient of determination R 2 Evaluate the regression model performance; S4.4.5, finding the best model hyperparameter combination.
8. A non-contact power calculation system for overhead lines based on random forest algorithm, characterized in that, The method comprises the following steps: an obtaining module configured to obtain current data of a user; The power calculation module is configured to input the preprocessed current data into a pre-established model to obtain a power calculation result. The model training process includes the following steps: S1, obtaining power grid basic data; S2, data preprocessing; S3, processing topology information; S4, using a random forest regressor to construct a regression model and training the model to obtain a pre-established model. The power grid basic data includes marketing management data, metering automation data, distribution network automation data, and dispatching automation system data; in the process of processing topology information, the pole number of the user and the automation switch is taken as line user information and input into the model for training. The step of inputting the preprocessed current data into the pre-established model to obtain the power calculation result specifically includes the following steps: calculating the RMS statistical index of the current data as one of the input features of the model; arranging the current data and the RMS statistical index into a DataFrame, and constructing a complete input feature set of the model with the obtained data information; preprocessing the data in the DataFrame, including missing value processing and standardization; when calculating the power using the trained model, the topology information is processed as follows: firstly, the comma-separated numerical string in the Tuopu column is converted into a numerical list; then, the length of each list is calculated to reflect the complexity of the topology structure; at the same time, the sum of the numerical values in the list is calculated; adding the numerical features obtained by parsing and converting the topology information to the DataFrame; inputting the DataFrame into the pre-trained model to output the power calculation result.
Citation Information
Patent Citations
Series arc fault detection method based on random forest
CN113552447A
Method and device for calculating residual power supply capacity of active overhead distribution line and medium
CN117895483A