Sample acquisition method, model construction method, device, equipment and storage medium
By hashing and masking the data in the power load forecasting method, combined with AES encryption and XOR operation, a gradient boosting tree model is constructed, which solves the problem of poor data security and improves the accuracy of model training and prediction precision.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA UNITED NETWORK COMM GRP CO LTD
- Filing Date
- 2023-08-09
- Publication Date
- 2026-05-08
AI Technical Summary
Existing power load forecasting methods suffer from poor data security during training.
The participant data is encrypted through hashing and masking. The feature parameters are masked using the AES encryption function, and the target mask hash value is generated through XOR operation to determine the target participant data. Combined with gradient boosting tree model training, data privacy protection and model training accuracy are improved.
This approach achieves data privacy protection in federated models while improving the accuracy of model training and prediction precision.
Smart Images

Figure CN117151242B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer natural language processing technology, and in particular to a sample acquisition method, model building method, apparatus, device and storage medium. Background Technology
[0002] Electricity load forecasting plays a crucial role in power system management. It guides power generation and supply, provides decision support, and ensures the safe and stable operation of the power system. In electricity load forecasting, data comes from multiple data providers, including various power companies, grid dispatch centers, and weather bureaus.
[0003] Currently, load forecasting methods are divided into two main categories: traditional classical forecasting and artificial intelligence forecasting. Both methods aim to find hidden patterns in historical electricity load data, build forecasting models, and use these models to predict future loads. Traditional forecasting methods include: Time series analysis: This method uses historical load data to build a model of load fluctuations over time and determines a load formula for forecasting; Regression analysis: This method uses the relationship between dependent and independent variables to construct a regression equation; Grey model method: This method treats all random processes as fluctuations and transforms random quantities into regular data; Trend extrapolation method: This method uses the laws of load fluctuations to find a function to predict the trend of load fluctuations; Artificial neural network method: This method constructs or learns different neural networks through message passing between neuron structures. Artificial intelligence forecasting methods include: Support vector machine: This method finds a plane to solve binary classification problems and performs global optimization based on statistics; Wavelet transform algorithm: This method uses signal frequency to change the sampling interval and can be combined with neural networks; Fuzzy theory method: This method uses researchers' experience to represent uncertain factors as functions and then transforms them into a computer-run method; Decision tree theory: This method is a classification and regression method. It is a tree structure that uses the characteristics of input data to classify instances; Random forest algorithm: This method is a classifier that includes many decision trees. It is a method that applies the idea of ensemble learning to put multiple decision trees together.
[0004] However, existing power load forecasting methods suffer from poor data security during training. Summary of the Invention
[0005] This application provides a sample acquisition method, a model building method, an apparatus, a device, and a storage medium to address the problem of poor data security during the training of existing power load forecasting methods.
[0006] Firstly, this application provides a sample acquisition method, including:
[0007] Obtain the data of the first participant, the data of the first parameter party includes the first sample and the first feature parameter corresponding to the first sample, wherein the first feature parameter has at least two types;
[0008] The first feature parameter corresponding to the first sample is hashed to obtain the hash value of the first feature parameter.
[0009] The hash value of the first feature parameter is masked to obtain the first mask hash value;
[0010] The first mask hash value and the second mask hash value are XORed to obtain the target mask hash value. The second mask hash value is obtained by the second participation method after performing hash processing and mask processing on the data of the second participant in sequence. The second participant is a participant in the federated model that is different from the first participant.
[0011] Based on the target mask hash value, the hash value of the first feature parameter is masked to obtain the first target mask hash value;
[0012] Based on the first target mask hash value and the second target mask hash value, the target first participant data is determined from the first participant data, wherein the second target mask hash value is the mask hash value obtained by the second participant after masking the hash value of the second feature parameter based on the target mask hash value.
[0013] In this embodiment of the application, the hash value of the first feature parameter is masked to obtain the first mask hash value, including:
[0014] Determine the preset AES encryption function;
[0015] The first hash feature parameter is masked according to the AES encryption function to obtain the first mask parameter.
[0016] In this embodiment of the application, determining the target first participant data from the first participant data based on the first target mask hash value and the second target mask hash value includes:
[0017] Based on the first target mask hash value and the second target mask hash value, determine the same target mask hash value;
[0018] Based on the same target mask hash value, samples with the same target are identified;
[0019] Based on the target identical samples, determine the target first sample from the first sample, and the target first feature parameter corresponding to the target first sample, wherein the target first sample is a first sample that is different from the target identical samples;
[0020] Based on the first target sample and the first target feature parameters, determine the data of the first target participant.
[0021] In this embodiment of the application, after determining the target first participant data from the first participant data based on the first target mask hash value and the second target mask hash value, the method further includes:
[0022] Based on the first characteristic parameter of the target, determine the first range of values for the first characteristic parameter of the target;
[0023] The first value range is sent to the model trainer so that after receiving the first and second value ranges, the model trainer can determine the target value range and obtain feature binning data based on the target value range. The second value range is the value range of the target second feature parameter sent by the second participant. The target second feature parameter is obtained based on the second sample and the target identical sample. The second sample is the sample in the second parameter data.
[0024] Receive feature-based binning data;
[0025] Based on the feature binning data and the target first parameter square data, the first gradient information is obtained;
[0026] The first gradient information is sent to the model trainer so that the model trainer can train the federated model based on the first gradient information and the second gradient information. The second gradient information is the gradient information obtained by the second participant based on the feature binning data and the target second parameter data. The target second parameter data is the target second participant data determined from the second participant data based on the first target mask hash value and the second target mask hash value.
[0027] In this embodiment of the application, the first gradient information is obtained based on the feature binning data and the target first parameter square data, including:
[0028] Based on the first parameter square data of the target, the objective function of the gradient boosting tree, as well as the first and second derivatives of the objective function, are determined. The objective function of the gradient boosting tree is obtained based on the sample label value, which is the label corresponding to the first sample.
[0029] The first gradient information is obtained based on the first and second derivatives of the objective function and the feature binning data.
[0030] Secondly, this application provides a model construction method, including:
[0031] The system receives a first value range of a first target feature parameter sent by a first target participant and a second value range of a second target feature parameter sent by a second target participant, wherein the first target participant and the second target participant are the first participant and the second participant in the sample processing method, and the first target feature parameter and the second target feature parameter are target first participant data obtained according to the sample processing method; and determines the target data range of the target feature parameter based on the first value range of the first target feature parameter and the second value range of the second target feature parameter.
[0032] The target data range of the target feature parameter is determined based on the first value range of the first target feature parameter and the second value range of the second target feature parameter.
[0033] The target data interval is subjected to feature binning to obtain binned gradient interval data;
[0034] The binning gradient interval data is sent to the first target participant and the second target participant, so that the first target participant can obtain the first gradient information based on the binning gradient interval data and the first sample data, and send the first gradient information to the model trainer; and the second target participant can obtain the second gradient information based on the binning gradient data and the second sample data, and send the second gradient information to the model trainer.
[0035] Receive the first gradient information and the second gradient information, and construct a gradient boosting tree based on the first gradient information and the second gradient information;
[0036] Construct the target model based on the gradient boosting tree.
[0037] In this embodiment of the application, determining the target data range of the target feature parameter based on the first value range of the first target feature parameter and the second value range of the second target feature parameter includes:
[0038] Determine the first maximum value and the first minimum value within the first value interval;
[0039] Determine the second maximum and second minimum values within the second value interval;
[0040] Based on the first maximum value and the second maximum value, the target maximum value is determined;
[0041] Based on the first minimum value and the second minimum value, the target minimum value is determined;
[0042] Based on the maximum and minimum values of the target, the target data range of the target feature parameters is obtained.
[0043] In this embodiment of the application, receiving first gradient information and second gradient information, and constructing a gradient boosting tree based on the first gradient information and second gradient information, includes:
[0044] Receive the first gradient information and the second gradient information;
[0045] Based on the first gradient information and the second gradient information, the total gradient information of the first target participant and the second target participant is obtained;
[0046] Based on the total gradient information, determine the gain information of each target feature parameter;
[0047] A gradient boosting tree is constructed based on the gain information of each target feature parameter.
[0048] In this embodiment of the application, a gradient boosting tree is constructed based on the gain information of each target feature parameter, including:
[0049] Determine the target gain value from the gain information of each target feature parameter;
[0050] Based on the target gain value in the gain information of each target feature parameter, determine the split nodes of the gradient boosting tree to be constructed;
[0051] Construct the gradient boosting tree based on the split nodes of the tree to be built.
[0052] In this embodiment of the application, constructing a target model based on a gradient boosting tree includes:
[0053] The predicted value for this round is obtained based on the gradient boosting tree;
[0054] Based on the predicted values in this round, the sample label values are updated to obtain the updated sample label values;
[0055] Obtain the iteration number and the prediction value from the previous iteration, which is obtained from the gradient boosting tree of the previous iteration;
[0056] The model loss is obtained based on the previous and current forecast values;
[0057] Based on the number of iterations and the model loss, confirm whether the initial target model has converged;
[0058] If the initial target model converges, the initial target model is determined as the target model, and the target model is sent to the first participant and the second participant for short-term charge prediction.
[0059] If the target model does not converge, the updated sample label values are sent to the first and second participants to update the objective function of the gradient boosting tree, as well as the first and second derivatives of the objective function.
[0060] Thirdly, this application provides a sample acquisition device, comprising:
[0061] The acquisition module is used to acquire the data of the first participant. The data of the first parameter party includes a first sample and a first feature parameter corresponding to the first sample, wherein the first feature parameter has at least two types.
[0062] The first obtaining module is used to perform hash processing on the first feature parameter corresponding to the first sample to obtain the hash value of the first feature parameter;
[0063] The second module is used to perform masking on the hash value of the first feature parameter to obtain the first mask hash value;
[0064] The third module is used to perform XOR processing on the first mask hash value and the second mask hash value to obtain the target mask hash value. The second mask hash value is obtained by the second participation method after performing hash processing and mask processing on the second participant data in sequence.
[0065] The fourth module is used to perform masking processing on the hash value of the first feature parameter based on the target mask hash value to obtain the first target mask hash value;
[0066] The first determining module is used to determine the target first participant data from the first participant data based on the first target mask hash value and the second target mask hash value, wherein the second target mask hash value is the mask hash value obtained by the second participant after masking the hash value of the second feature parameter based on the target mask hash value.
[0067] Fourthly, this application provides a model building apparatus, comprising:
[0068] The first receiving module is used to receive a first value range of a first target feature parameter sent by a first target participant and a second value range of a second target feature parameter sent by a second target participant, wherein the first target participant and the second target participant are the first participant and the second participant in the sample processing method, and the first target feature parameter and the second target feature parameter are the target first participant data obtained by the sample processing method;
[0069] The second determining module is used to determine the target data range of the target feature parameter based on the first value range of the first target feature parameter and the second value range of the second target feature parameter.
[0070] The fifth module is used to perform feature binning on the target data interval to obtain binned gradient interval data;
[0071] The sending module is used to send binning gradient interval data to the first target participant and the second target participant, so that the first target participant can obtain the first gradient information based on the binning gradient interval data and the first sample data, and send the first gradient information to the model trainer; and the second target participant can obtain the second gradient information based on the binning gradient data and the second sample data, and send the second gradient information to the model trainer.
[0072] The first construction module is used to receive the first gradient information and the second gradient information, and to construct a gradient boosting tree based on the first gradient information and the second gradient information.
[0073] The second building module is used to construct the target model based on the gradient boosting tree.
[0074] Fifthly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0075] The memory stores the instructions that the computer executes;
[0076] The processor executes computer execution instructions stored in memory to implement the method of this application.
[0077] In a sixth aspect, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method of this application.
[0078] This application provides a sample acquisition method, model construction method, apparatus, device, and storage medium. The method involves acquiring first participant data, where the first parameter data includes a first sample and a first feature parameter corresponding to the first sample, wherein the first feature parameter has at least two types. The method performs hash processing on the first feature parameter corresponding to the first sample to obtain a hash value for the first feature parameter. It then performs masking processing on the hash value for the first feature parameter to obtain a first mask hash value. Finally, it performs XOR processing on the first mask hash value and the second mask hash value to obtain a target mask hash value. The second mask hash value is obtained by a second participation method that sequentially performs hashing and masking processing on the second participant data. The second participant is a participant in the federated model that is different from the first participant. Based on the target mask hash value, the first feature parameter hash value is masked to obtain a first target mask hash value. Finally, based on the first target mask hash value... The target first participant data is determined from the first participant data using the second target mask hash value. The second target mask hash value is the mask hash value obtained by the second participant after masking the hash value of the second feature parameter based on the target mask hash value. Simultaneously, the model trainer receives gradient information from each participant and calculates the gain value of the binning result for each feature attribute in the gradient information. Based on the binning result of the maximum gain value for each feature attribute, a new gradient boosting tree is obtained. Through iteration, multiple gradient boosting trees are obtained, completing the model construction. The model is then sent to each participant for short-term power load forecasting. The mask obtained through hash encryption ensures the privacy of the model training data. Furthermore, through iteration, the gradient boosting tree in this round obtains new nodes based on the binning result of the maximum gain value for each feature attribute. The increase in data volume and the gradient boosting tree improve the accuracy of model training. Attached Figure Description
[0079] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0080] Figure 1 A schematic flowchart illustrating a sample acquisition method provided in an embodiment of this application;
[0081] Figure 2 A flowchart illustrating another sample acquisition method provided in an embodiment of this application;
[0082] Figure 3 A flowchart illustrating a model building method provided in an embodiment of this application;
[0083] Figure 4 A flowchart illustrating another model construction method provided in an embodiment of this application;
[0084] Figure 5This is a schematic diagram of the sample acquisition device provided in the embodiments of this application;
[0085] Figure 6 This is a schematic diagram of the structure of the model building apparatus provided in the embodiments of this application;
[0086] Figure 7 This is a schematic diagram of the electronic device structure provided in an embodiment of this application.
[0087] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0088] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0089] Electricity load forecasting plays a crucial role in power system management, guiding power generation and supply, providing decision support, and ensuring the safe and stable operation of the power system. However, traditional electricity load forecasting methods suffer from several drawbacks. Firstly, data silos and privacy issues exist. Secondly, some existing deep learning models used for electricity load forecasting have limitations, such as: Time series models (requiring accurate data, lacking self-learning capabilities, and failing to meet forecasting accuracy requirements); Grey model methods (failing to reflect periodicity and having scattered data, leading to poor forecasting results); Trend extrapolation methods (not considering other factors, and large load fluctuations can lead to inaccurate forecasts); Artificial neural networks (the connection method affects forecasting results, and some parameters lack definitive basis); Vector machines (the kernel function directly affects load forecasting, and improper parameter selection can reduce accuracy); Wavelet transform algorithms (focusing only on load characteristics and ignoring external factors); Fuzzy theory methods (subjective human factors can alter forecasts); Decision tree theory (difficult to obtain a simple model and poor generalization to data); and Random forest algorithms (fitting issues can occur in noisy partitioning and regression problems). In summary, existing load forecasting techniques suffer from insufficient forecasting accuracy.
[0090] To address the aforementioned problems, this application provides a sample acquisition method, model construction method, apparatus, device, and storage medium. The method involves acquiring data from a first participant, where the first parameter data includes a first feature parameter corresponding to a first sample; hashing the first feature parameter to obtain a hash value; masking the hash value to obtain a first mask hash value; XORing the first mask hash value with a second mask hash value to obtain a target mask hash value; the second participant is a participant in the federated model that differs from the first participant; and masking the first feature parameter hash value based on the target mask hash value to obtain a first target mask hash value; and then XORing the first target mask hash value with... The second target mask hash value determines the target first participant's data; simultaneously, the model trainer receives gradient information from each participant, calculates the gain value of the binning result for each feature attribute in the gradient information, and obtains a new gradient boosting tree based on the binning result of the maximum gain value of each feature attribute. Through iteration, multiple gradient boosting trees are obtained, completing the model construction, and then the model is sent to each participant for short-term power load forecasting. Among these, the mask obtained through hash encryption ensures the privacy of the model training data, and through iteration, the gradient boosting tree in this round obtains new nodes based on the binning result of the maximum gain value of each feature attribute. The increase in data volume and the gradient boosting tree can improve the accuracy of model training.
[0091] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0092] This application provides a sample acquisition method. The execution subject can be a server, which can be a mobile phone, tablet, computer or other device. This embodiment does not impose any special restrictions on the implementation of the execution subject. As long as the executing entity can obtain the data of the first participant, the data of the first parameter includes the first sample and the first feature parameter corresponding to the first sample, wherein there are at least two kinds of first feature parameters; the first feature parameter corresponding to the first sample is hashed to obtain the hash value of the first feature parameter; the hash value of the first feature parameter is masked to obtain the first mask hash value; the first mask hash value and the second mask hash value are XORed to obtain the target mask hash value, wherein the second mask hash value is the mask hash value obtained by the second participating method after hashing and masking the data of the second participant in sequence, and the second participant is a participant in the federated model that is different from the first participant; according to the target mask hash value, the first feature parameter hash value is masked to obtain the first target mask hash value; according to the first target mask hash value and the second target mask hash value, the target first participant data is determined from the data of the first participant, wherein the second target mask hash value is the mask hash value obtained by the second participant after masking the hash value of the second feature parameter according to the target mask hash value.
[0093] This application provides a model building method. The execution subject can be a server, which can be a mobile phone, tablet, computer or other device. This embodiment does not impose any special restrictions on the implementation of the execution subject. As long as the executing entity can receive the first value range of the first target feature parameter sent by the first target participant and the second value range of the second target feature parameter sent by the second target participant, wherein the first target participant and the second target participant are the first participant and the second participant in the sample processing method, and the first target feature parameter and the second target feature parameter are the target first participant data obtained by the sample processing method; determine the target data range of the target feature parameter based on the first value range of the first target feature parameter and the second value range of the second target feature parameter; perform feature binning processing on the target data range to obtain binned gradient range data; send the binned gradient range data to the first target participant and the second target participant, so that the first target participant can obtain the first gradient information based on the binned gradient range data and the first sample data, and send the first gradient information to the model trainer, and the second target participant can obtain the second gradient information based on the binned gradient data and the second sample data, and send the second gradient information to the model trainer; receive the first gradient information and the second gradient information, and construct a gradient boosting tree based on the first gradient information and the second gradient information; construct the target model based on the gradient boosting tree.
[0094] The following are explanations of the terms used in this application:
[0095] Hash: Generally translated as hashing, hashing, or transliterated as hash, it is a function that transforms an input of arbitrary length (also called a pre-image) into a fixed-length output using a hash algorithm. This output is the hash value. This transformation is a compression mapping, meaning that the space of hash values is usually much smaller than the space of inputs. Different inputs may hash to the same output, so it is impossible to determine a unique input value from the hash value. Simply put, it is a function that compresses a message of arbitrary length into a message digest of a fixed length.
[0096] AES (Advanced Encryption Standard), also known as Rijndael encryption, is a block cipher standard adopted by the U.S. federal government. This standard replaced the earlier DES (Data Encryption Standard) and has been extensively analyzed and widely used worldwide. After a five-year selection process, AES was published by the National Institute of Standards and Technology (NIST) on November 26, 2001, in FIPS PUB 197, and became an effective standard on May 26, 2002. By 2006, AES had become one of the most popular algorithms for symmetric-key encryption. The key is fundamental to the encryption and decryption of the AES algorithm. Symmetric encryption algorithms are symmetric because they require the same key for both encryption and decryption of plaintext.
[0097] A decision tree is a tree structure in which each internal node represents a test on an attribute, each branch represents a test output, and each leaf node represents a category.
[0098] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0099] Figure 1 This is a schematic flowchart illustrating the sample acquisition method provided in an embodiment of this application. Figure 1 As shown, the execution subject of this method can be a server or other servers; this embodiment does not impose any special restrictions here. Figure 1 As shown, the method includes:
[0100] S101. Obtain the data of the first participant. The data of the first parameter includes the first sample and the first feature parameter corresponding to the first sample. The first feature parameter has at least two types.
[0101] The first parameter data refers to charge data, the first sample refers to different rows of charge data distinguished by ID (Identity document), and each row corresponds to a power load number. The first feature parameter refers to the charge generated by a certain power generation method, which can specifically refer to the charge generated by wind power generation or the charge generated by hydropower generation.
[0102] S102. Perform hash processing on the first feature parameter corresponding to the first sample to obtain the hash value of the first feature parameter.
[0103] Hash processing refers to mapping the first feature parameter to a shorter data segment using a hash algorithm. This shorter data segment is the hash value of the first feature parameter. The hash algorithm can be MD5 (message-digest algorithm 5), SHA (Secure Hash Algorithm) series algorithms, or CRC (Cyclic Redundancy Check) algorithm.
[0104] S103. Perform masking on the hash value of the first feature parameter to obtain the first mask hash value;
[0105] The first mask hash value is the ciphertext encrypted with the hash value of the first feature parameter.
[0106] Masking refers to obtaining the first mask hash value by encrypting the hash of the first feature parameter. Masking can be achieved by encrypting the hash value of the first feature parameter using the AES encryption algorithm.
[0107] In this embodiment of the application, the hash value of the first feature parameter is masked to obtain the first mask hash value, including:
[0108] Determine the preset AES encryption function;
[0109] The first hash feature parameter is masked according to the AES encryption function to obtain the first mask parameter.
[0110] The AES encryption function can be a symmetric encryption algorithm, where the AES encryption key and decryption key are the same. The first participant encrypts the AES key using RSA (an asymmetric encryption algorithm) and transmits it to the second participant, who then decrypts it to obtain the AES key. The second participant then uses the AES key to communicate. The RSA ciphertext represents the result of raising the plaintext to the power of E and modifying it by N. This is done by multiplying the plaintext by itself to the power of E, dividing the result by N, and taking the remainder. E and N together form the public key. When encrypting plaintext, the AES algorithm breaks it down into individual plaintext blocks, each 128 bits long. If a plaintext block is shorter than 128 bits, it is padded with additional characters. By processing these plaintext blocks with the AES encryptor, independent ciphertext blocks are generated. These ciphertext blocks are then concatenated to obtain the AES encryption result.
[0111] S104. Perform an XOR operation on the first mask hash value and the second mask hash value to obtain the target mask hash value. The second mask hash value is obtained by performing hash and mask operations on the second participant data in sequence using the second participation method. The second participant is a participant in the federated model that is different from the first participant.
[0112] The target mask hash value is obtained by XORing the first mask hash value and the second mask hash value.
[0113] XOR, also known as half-addition, is equivalent to binary addition without carry: in binary, 1 represents true and 0 represents false. If the corresponding bits of the two values involved in the operation are the same, the result is 0; otherwise, it is 1.
[0114] In the second participant, the target mask hash value is obtained by XORing the second mask hash value and the first mask hash value. Here, it is necessary to ensure that the target mask hash value of the first participant and the target mask hash value of the second participant are equal.
[0115] S105. Based on the target mask hash value, perform masking processing on the hash value of the first feature parameter to obtain the first target mask hash value.
[0116] Among them, mask processing refers to performing an XOR operation on the target mask hash value and the hash value of the first feature parameter. The XOR operation is also called half addition, and its operation rule is equivalent to binary addition without carry: compare the value of each bit of the target mask hash value and the hash value of the first feature parameter. If the two corresponding bits are the same, the result is 0, otherwise it is 1.
[0117] S106. Based on the first target mask hash value and the second target mask hash value, determine the target first participant data from the first participant data, wherein the second target mask hash value is the mask hash value obtained by the second participant after masking the hash value of the second feature parameter based on the target mask hash value.
[0118] Among them, the target first participant data refers to each power generation method and the corresponding power generation range of each power generation method.
[0119] In this embodiment of the application, after determining the target first participant data from the first participant data based on the first target mask hash value and the second target mask hash value, the method further includes:
[0120] Based on the first characteristic parameter of the target, determine the first range of values for the first characteristic parameter of the target;
[0121] The first value range is sent to the model trainer so that after receiving the first and second value ranges, the model trainer can determine the target value range and obtain feature binning data based on the target value range. The second value range is the value range of the target second feature parameter sent by the second participant. The target second feature parameter is obtained based on the second sample and the target identical sample. The second sample is the sample in the second parameter data.
[0122] Receive feature-based binning data;
[0123] Based on the feature binning data and the target first parameter square data, the first gradient information is obtained;
[0124] The first gradient information is sent to the model trainer so that the model trainer can train the federated model based on the first gradient information and the second gradient information. The second gradient information is the gradient information obtained by the second participant based on the feature binning data and the target second parameter data. The target second parameter data is the target second participant data determined from the second participant data based on the first target mask hash value and the second target mask hash value.
[0125] Among them, the first characteristic parameter of the target refers to each power generation method held by the first participant and the corresponding charge number of each power generation method. The power generation method can be wind power generation, thermal power generation, or hydropower generation, and each power generation method corresponds to a column of power generation charge number.
[0126] The first value range of the first characteristic parameter of the target refers to the range of the number of charges generated by each power generation method held by the first participant. The range of the number of charges generated by each power generation method is obtained by statistically analyzing the data in the corresponding column of power generation methods.
[0127] The second value range of the second characteristic parameter of the target refers to the range of the charge generation data of each power generation method held by the second participant. The range of the charge generation of each power generation method is obtained by statistically analyzing the data of the corresponding column of power generation methods.
[0128] If the data of the second participant and the data of the first participant come from the same designated region, the power generation methods are consistent, the number of power generation devices is fixed, the power generation methods in the first characteristic parameter and the second characteristic parameter are consistent, but the number of generated charges corresponding to each power generation method is different.
[0129] The target value range refers to the value range obtained by merging the first value range and the second value range.
[0130] The feature binning data comes from the aggregation server. After confirming the target value range, the aggregation server divides the target value range into sub-target value ranges with the same range. For example, if the target value range is [a, b], then the sub-target value ranges can be [a1, b1], [a2, b2]...[an, bn]. The length of the value range [a1, b1] is equal to the length of any other sub-target value range.
[0131] In this embodiment of the application, the first gradient information is obtained based on the feature binning data and the target first parameter square data, including:
[0132] Based on the first parameter square data of the target, the objective function of the gradient boosting tree, as well as the first and second derivatives of the objective function, are determined. The objective function of the gradient boosting tree is obtained based on the sample label value, which is the label corresponding to the first sample and used to characterize the number of power loads.
[0133] The first gradient information is obtained based on the first and second derivatives of the objective function and the feature binning data.
[0134] In this process, gradient boosting trees are used to predict electricity load. The current gradient boosting tree is generated based on the previous gradient boosting tree, which yields the electricity load prediction from the previous round. The current gradient boosting tree updates the first and second derivatives of the objective function based on the electricity load prediction from the previous round, thereby affecting the gradient information updates of the first and second participants. The gradient information includes the sum of the first and second derivatives of the left subtrees, the right subtrees, and all attribute features of the previous gradient boosting tree. Based on the sum of the first and second derivatives of the left and right subtrees of all attribute features, the gain value of all nodes can be calculated. By comparing the gain values of all attribute features of the previous gradient boosting tree, the attribute feature corresponding to the maximum value is set as the current split point of the tree, and a new node is generated. The current gradient boosting tree is then generated based on the new node.
[0135] The label refers to the predicted power load value obtained from the gradient boosting tree.
[0136] Substituting the predicted electricity load value into the objective function, we obtain the first derivative of the objective function by taking its first derivative and the second derivative by taking its second derivative. The objective function of the gradient boosting tree is to minimize the loss function. In each iteration, the gradient boosting tree calculates the difference between the current prediction and the previous prediction, and then uses the current prediction as the new target variable to continue training the next tree. Finally, the prediction result is obtained.
[0137] Figure 2 This is a flowchart illustrating another sample acquisition method provided in an embodiment of this application. Figure 2 As shown, the execution subject of this method can be a server or other servers; this embodiment does not impose any special restrictions here. Figure 2 As shown, the method includes:
[0138] S201, Participant A obtains the hash value Hv A Participant B receives the hash value Hv B .
[0139] The method for calculating the hash value is as follows:
[0140] Participants A and B each hold data {UId A ,F(UId A )} and {UId B ,F(UId B Participant A performs hash processing on the data to obtain the hash value Hv. A =H A (F(UId AParticipant B performs hash processing on the data to obtain the hash value Hv. B =H B (F(UId B )), where UId A ,UId B Let F(UId) represent the sample Id sets of participant A and participant B, respectively. A )F(UId B ) represent the features corresponding to participant A and participant B and sample Id, respectively.
[0141] S202, Participant A, based on the hash value Hv A Obtain the random mask M A Participant B, based on the hash value Hv B Obtain the random mask M B .
[0142] The method for calculating the random mask is as follows: Participant A uses the AES encryption function to generate a random mask M. A =F AES (Hv A Participant B uses the AES encryption function to generate a random mask M. B =F AES (Hv B Participants A and B use random masks to conceal their respective hash values.
[0143] S203, Participant A will use a random mask M A Send it to participant B, and participant B will send a random mask M. B Send to participant A.
[0144] S204, Participant A will use mask M A and M B Perform an XOR operation to obtain a new mask. Participant B will use mask M B and M A Perform an XOR operation to obtain a new mask. ensure
[0145] S205, Participant A uses a new mask Masking your own hash value to obtain the masked hash value MHv A Participant B uses a new mask. Masking your own hash value to obtain the masked hash value MHv B .
[0146] The method for calculating the mask hash value is as follows: Participant A uses a new mask. Mask your hash value to get the masked hash value Participant B uses a new mask Mask your hash value to get the masked hash value
[0147] S206, Participant A will send the mask hash value MHv A Send it to participant B, and participant B will send the mask hash value MHv B Send to participant A.
[0148] S207. Remove duplicate data and obtain the XOR dataset.
[0149] The method for removing duplicate data and obtaining the XOR dataset is as follows:
[0150] Participant A and Participant B will each transfer MHv A With MHv B A comparison is performed; if they are equal, it means the data of the two samples is the same. By comparing the mask hash values of each sample one by one, the common sample ID set UId is obtained. c =UId A ∩UId B Participant A and Participant B each receive their own set of sample IDs, UId1 = UId. A -UId c UId2 = UId B Alternatively, participant A and participant B each obtain their respective set of sample IDs, UId1 = UId. A UId2 = UId B -UId c .
[0151] S208. Participant A statistically analyzes the sample value range [Max] for each attribute feature. A Min A ] j The data is then sent to the aggregation server. Participant B, based on its data {UId2, F(UId2)}, calculates the range of sample values [Max] for each attribute feature. B Min B ] j And send it to the aggregation server.
[0152] Where j represents the j-th characteristic attribute value among the participants.
[0153] S209, Participant A will generate the gradient histogram. A Sending the gradient histogram to the aggregation server, participant B will send the histogram to the aggregation server. B Send to the aggregation server.
[0154] Among them, the gradient histogram (Hist) A and gradient histogram Histogram B The method for obtaining it is as follows:
[0155] Participant A and Participant B, based on their respective data {UId1, F(UId1)} and {UId2, F(UId2)}, calculate the objective function of the current k-th tree as follows:
[0156]
[0157] First derivative of the objective function:
[0158]
[0159] The second derivative of the objective function:
[0160]
[0161] in,
[0162] y i This represents the actual sample label value (i.e., the actual number of electricity loads). Let ∑ represent the sample label value (i.e., the predicted electricity load), k represent the k-th gradient boosting tree, and ∑ k Ω(f k ) represents the regularization term, f k Let T be the k-th tree model, where T represents the number of leaf nodes, ω represents the leaf weight value, γ represents the leaf tree penalty regularization term, and λ represents the leaf weight penalty regularization term. In the first iteration, the sample label value (i.e. the predicted power load) is preset by the user.
[0163] Participant A and Participant B each calculated {g} based on their respective results. i g i} and binning results [d1, d2, ..., d n ] j Calculate the local feature bins [{G1, H1}, {G2, H2}, ...,
[0164]
[0165] The gradient histogram is sent to the aggregation server, and participant B sends it to the aggregation server. B Send to the aggregation server. Where G = ∑g i H = ∑h i In each pair {G i H i} contains information {{G L GR},{H L H R}}; where G L G R H L H R These are the first and second derivatives of the left and right subtrees, respectively, based on their respective attribute feature values.
[0166] In the sample acquisition method, each participant uses local data for training. They only need to upload the model parameters obtained from local training to a centralized server, and then the aggregator aggregates these parameters to obtain global model parameters. This reduces the risk of data leakage, privacy infringement, and information tampering, and ensures data privacy and security.
[0167] Figure 3 This is a flowchart illustrating a model building method provided in an embodiment of this application. Figure 3 As shown, the execution subject of this method can be a server or other servers; this embodiment does not impose any special restrictions here. Figure 3 As shown, the method includes:
[0168] S301. Receive the first value range of the first target feature parameter sent by the first target participant and the second value range of the second target feature parameter sent by the second target participant, wherein the first target participant and the second target participant in the sample processing method, and the first target feature parameter and the second target feature parameter are target first participant data obtained according to the sample processing method.
[0169] In this scenario, the first objective participant can be the power grid. The second objective participant can be the energy provider. The first and second objective participants are different data providers used for model training.
[0170] The first target feature parameters refer to all the feature parameters held by the first target participant.
[0171] The second objective feature parameters refer to all the feature parameters held by the second objective participants.
[0172] In the embodiments of this application, both the first target feature parameter and the second target feature parameter can be obtained by the sample acquisition method provided in the above embodiments. That is, when the first target participant is the first participant in the sample acquisition method, the second target participant can be the second participant in the sample acquisition method, and when the second target participant is the first participant in the sample acquisition method, the first target participant can be the second participant in the sample acquisition method.
[0173] The first and second target feature parameters originate from different participants, and their represented feature attributes can be matched one-to-one, but their values differ. The first value range refers to the value range corresponding to each feature parameter held by the first participant, which can be denoted as [Max...]. A Min A ] j j In the first participant, the j-th attribute feature column of all attribute parameters can be, for example, the second attribute feature column of the attribute parameter in the first participant can be generation biomass, with a corresponding value range of [0, 300]. So the value range of generation biomass is recorded as [0, 300]2.
[0174] The second value range refers to the range of values corresponding to each feature parameter held by the second participant, which can be denoted as [Max]. B, Min B ] j , where j represents the j-th individual characteristic column among all attribute parameters of the second participant. For example, in the second participant, the fourth attribute characteristic column of the attribute parameter can be megawatt-level coal gas generation (MW), with a corresponding value range of [0, 0]. Therefore, the value range of megawatt-level coal gas generation is [0, 0]4.
[0175] S302. Determine the target data range of the target feature parameter based on the first value range of the first target feature parameter and the second value range of the second target feature parameter.
[0176] Specifically, the attribute features held by the first participant and their corresponding value ranges, and the attribute features held by the second participant and their corresponding value ranges are merged to obtain the target attribute feature parameters. All attribute features of the first participant and the second participant are the same.
[0177] In this embodiment of the application, determining the target data range of the target feature parameter based on the first value range of the first target feature parameter and the second value range of the second target feature parameter includes:
[0178] Determine the first maximum value and the first minimum value within the first value interval;
[0179] Determine the second maximum and second minimum values within the second value interval;
[0180] Based on the first maximum value and the second maximum value, the target maximum value is determined;
[0181] Based on the first minimum value and the second minimum value, the target minimum value is determined;
[0182] Based on the maximum and minimum values of the target, the target data range of the target feature parameters is obtained.
[0183] The maximum target value is the larger of the first maximum value and the second maximum value.
[0184] The minimum target value is the smaller of the first minimum value and the second minimum value.
[0185] The target data interval of the target feature parameter is obtained by merging the first value interval of the first target feature parameter and the second value interval of the second target feature parameter, wherein the minimum value of the target data interval is the minimum value of the target, and the maximum value is the maximum value of the target.
[0186] S303. Perform feature binning on the target data interval to obtain binned gradient interval data.
[0187] Feature binning refers to dividing the target data interval into several sub-intervals of equal length, where the length of each sub-interval does not exceed half the length of the target data interval. All sub-intervals of equal length constitute the binned gradient interval data. For example, if the target data interval is [10, 100], then the length of the target data interval in the binned gradient interval is 100 - 10 = 90. Therefore, the length of each sub-interval cannot exceed 45, but can be 20. Thus, the binned gradient interval data could be [10, 30], [31, 51], or [52, 72].
[0188] [73, 93], [94, 100]; the sub-interval length can be 30, so the binning gradient interval data can be [10, 40], [41, 71], [72, 100].
[0189] S304. Send the binning gradient interval data to the first target participant and the second target participant, so that the first target participant can obtain the first gradient information based on the binning gradient interval data and the first sample data, and send the first gradient information to the model trainer, and the second target participant can obtain the second gradient information based on the binning gradient data and the second sample data, and send the second gradient information to the model trainer.
[0190] The first sample data includes the first feature parameter and the sample label value.
[0191] The second sample data includes the second feature parameter and the sample label value.
[0192] When the model undergoes its first iteration, the sample label values need to be preset manually.
[0193] S305. Receive the first gradient information and the second gradient information, and construct a gradient boosting tree based on the first gradient information and the second gradient information.
[0194] Gradient boosting trees can refer to decision trees, which are tree-like structures where each internal node represents a test on an attribute (i.e., a feature attribute), each branch represents a test output (i.e., a sample label value), and each leaf node represents a category (i.e., a range of values corresponding to a feature parameter). The gradient boosting tree generated in the next round is more accurate in its predictions than the gradient boosting tree generated in the previous round.
[0195] Constructing a gradient boosting tree can refer to the process of obtaining a gradient boosting tree by using a secure aggregation technique on the first and second gradient information. The secure aggregation technique can refer to the technique of allowing multiple participants to jointly train the model without sharing the original data. Secure aggregation techniques can include secure aggregation algorithms, differential privacy, secure aggregation communication, participant authentication and authorization, model merging strategies, and transfer learning.
[0196] In this embodiment of the application, receiving first gradient information and second gradient information, and constructing a gradient boosting tree based on the first gradient information and second gradient information, includes:
[0197] Receive the first gradient information and the second gradient information;
[0198] Based on the first gradient information and the second gradient information, the total gradient information of the first target participant and the second target participant is obtained;
[0199] Based on the total gradient information, determine the gain information of each target feature parameter;
[0200] A gradient boosting tree is constructed based on the gain information of each target feature parameter.
[0201] The total gradient information includes the first derivative of the left subtree, the first derivative of the right subtree, the second derivative of the left subtree, and the second derivative of the right subtree for each feature parameter.
[0202] Calculate the gain value corresponding to each attribute feature partition to obtain the partition of each attribute corresponding to the maximum gain value. Place other partitions whose actual values are less than the attribute partitions corresponding to the maximum gain value on the left, which is the left subtree; place other partitions whose actual values are less than the attribute partitions corresponding to the maximum gain value on the right, which is the right subtree.
[0203] The gain value of each feature parameter can be calculated based on the first derivative of the left subtree, the first derivative of the right subtree, the second derivative of the left subtree, and the second derivative of the right subtree for each feature attribute. A gradient boosting tree is then generated based on the feature parameter corresponding to the largest gain value.
[0204] In this embodiment of the application, a gradient boosting tree is constructed based on the gain information of each target feature parameter, including:
[0205] Determine the target gain value from the gain information of each target feature parameter;
[0206] Based on the target gain value in the gain information of each target feature parameter, determine the split nodes of the gradient boosting tree to be constructed;
[0207] Construct the gradient boosting tree based on the split nodes of the tree to be built.
[0208] The target gain value is the maximum gain value.
[0209] S306. Construct the target model based on the gradient boosting tree.
[0210] The gradient boosting tree is generated through multiple iterations, with one gradient boosting tree generated in each iteration. The gradient boosting tree generated in this iteration is based on the gradient boosting tree generated in the previous iteration, and the error of the prediction value obtained based on the gradient boosting tree generated in this iteration is smaller than the error value obtained based on the gradient boosting tree generated in the previous iteration.
[0211] In this embodiment of the application, constructing a target model based on a gradient boosting tree includes:
[0212] The predicted value for this round is obtained based on the gradient boosting tree;
[0213] The sample label values are updated based on the predicted values from this round, resulting in updated sample label values;
[0214] Obtain the iteration number and the prediction value from the previous iteration, which is obtained from the gradient boosting tree of the previous iteration;
[0215] The model loss is obtained based on the previous and current forecast values;
[0216] Based on the number of iterations and the model loss, confirm whether the initial target model has converged;
[0217] If the initial target model converges, the initial target model is determined as the target model, and the target model is sent to the first participant and the second participant for short-term charge prediction.
[0218] If the target model does not converge, the updated sample label values are sent to the first and second participants to update the objective function of the gradient boosting tree, as well as the first and second derivatives of the objective function.
[0219] The predicted value for this round is the number of power loads obtained from the gradient boosting tree generated in this round of iteration.
[0220] If the actual number of iterations reaches the preset number of iterations, the model converges.
[0221] The model loss is the difference between the current forecast value and the previous forecast value. The current forecast value refers to the power load predicted in this round, and the previous forecast value can refer to the power load predicted in the previous round.
[0222] If the model loss is within the preset range, it means that the model prediction is stable and the model can converge.
[0223] If the model converges, the updated sample label values are sent to the first and second participants. Based on the new sample label values, the first and second derivatives of the objective function of the gradient boosting tree are updated, so that all participants can update their own gradient information.
[0224] Figure 4 This is a flowchart illustrating a model building method provided in an embodiment of this application. Figure 4 As shown, the execution subject of this method can be a server or other servers; this embodiment does not impose any special restrictions here. Figure 4 As shown, the method includes:
[0225] S401. The aggregation server obtains the feature binning results of the sample values under each attribute feature and sends the feature binning results to participant A and participant B.
[0226] The method for obtaining the feature binning results for the sample values under each attribute feature is as follows:
[0227] Obtain the range of sample values [Max] for each attribute feature of participant A. A Min A ] j Obtain the sample value range [Max] for each attribute feature of participant B. B Min B ] j The aggregation server is based on the range of sample values [Max] for each aligned attribute feature. C Min C ] j Perform equidistant binning to obtain the feature binning results [d1, d2, d3, ..., dn] for the sample values under each attribute feature. j With party A and participant B, where the subscript j represents the j-th attribute feature column, d1 and d2 represent the equally spaced value ranges for each attribute feature, and the aggregation server uses the Max method to determine the sample value ranges for each attribute feature. C =Max(Max A Max B ), Min C =Min(Min A Min B ).
[0228] S402, The aggregation server uses the gradient information Hist from participant A. A Hist information of participant B B The total gradient information Hist of all participants is obtained using secure aggregation technology. C =Hist A +Hist B .
[0229] Among them, secure aggregation technology is designed to protect data security and privacy when it comes to horizontal federated learning, so that multiple parties can participate in training the model together without sharing the original data. Secure aggregation technology includes: secure aggregation algorithm, differential privacy, secure aggregation communication, participant authentication and authorization, model merging strategy, and transfer learning.
[0230] S403. The aggregation server constructs a gradient boosting tree based on the total gradient information, and calculates the gain corresponding to each attribute feature based on the gradient boosting tree.
[0231] The method for calculating the gain corresponding to each attribute feature partition is as follows:
[0232]
[0233] Among them, H L H represents the sum of the second derivatives of the left subtree. R G represents the sum of the second derivatives of the right subtree. L G represents the sum of the first derivatives of the left subtree. R Let λ represent the sum of the first derivatives of the right subtree, λ represent the leaf weight penalty regularization term, and γ represent the leaf weight penalty regularization term. Both λ and γ are parameters used to prevent the model from overfitting.
[0234] S404. The aggregation server compares the gain values under each attribute feature partition and sets the partition corresponding to the maximum value as the current split point of the tree and generates a new node. Based on the new node, it constructs the gradient boosting tree for this round.
[0235] S405. Based on the gradient boosting tree in this round, add up the values of all nodes in the tree to obtain new sample labels (i.e., power load tree), and update the sample labels.
[0236] S406, determine if the model has converged. If it has converged, send the trained model to participant A and participant B for short-term power load forecasting. If it has not converged, send new sample labels to the first and second participants for gradient information updates.
[0237] The method for determining model convergence is as follows: the model converges when it reaches a preset number of iterations of sixteen; the sample label values of the previous iteration and the sample values of the current iteration are obtained, and if the difference is within a preset range, the model converges.
[0238] In this model building method, each participant only needs to share the model parameters obtained from local training with other participants. The centralized server is responsible for aggregating the model parameters of each participant to obtain the global model parameters. The federated learning method can improve the generalization performance of the model while protecting data privacy, thereby obtaining better prediction results.
[0239] Figure 5 This is a structural example diagram illustrating the sample acquisition provided in an embodiment of this application. For example... Figure 5 As shown, the sample acquisition device 50 includes: an acquisition module 501, a first acquisition module 502, a second acquisition module 503, a third acquisition module 504, a fourth acquisition module 505, and a first determination module 506. Wherein:
[0240] The acquisition module 501 is used to acquire the data of the first participant. The data of the first participant includes a first sample and a first feature parameter corresponding to the first sample. The first feature parameter has at least two types.
[0241] The first obtaining module 502 is used to perform hash processing on the first feature parameter corresponding to the first sample to obtain the hash value of the first feature parameter, and the hash value of the first feature parameter corresponds to the first sample.
[0242] The second module 503 is used to perform masking processing on the hash value of the first feature parameter to obtain the first mask hash value;
[0243] The third module 504 is used to perform XOR processing on the first mask hash value and the second mask hash value of the iteration number to obtain the target mask hash value. The second mask hash value of the iteration number is the mask hash value obtained after the second participant method of the iteration number performs hash processing and mask processing on the data of the second participant in sequence. The second participant of the iteration number is a participant in the federated model that is different from the first participant of the iteration number.
[0244] The fourth module 505 is used to perform masking processing on the hash value of the first feature parameter based on the target mask hash value to obtain the first target mask hash value;
[0245] The first determining module 506 is used to determine the target first participant data from the first participant data based on the first target mask hash value and the second target mask hash value, wherein the second target mask hash value is the mask hash value obtained by the second participant after masking the hash value of the second feature parameter based on the target mask hash value.
[0246] In this embodiment of the application, the second obtaining module 503 can be specifically used for:
[0247] Determine the preset AES encryption function;
[0248] The first hash feature parameter is masked according to the AES encryption function to obtain the first mask parameter.
[0249] In this embodiment of the application, the first determining module 506 can specifically be used for:
[0250] Based on the first target mask hash value and the second target mask hash value, determine the same target mask hash value;
[0251] Based on the same target mask hash value, samples with the same target are identified;
[0252] Based on the target identical samples, determine the target first sample from the first sample, and the target first feature parameter corresponding to the target first sample, wherein the target first sample is a first sample that is different from the target identical samples;
[0253] Based on the first target sample and the first target feature parameters, determine the data of the first target participant.
[0254] In this embodiment of the application, the first determining module 506 can specifically be used for:
[0255] Based on the first characteristic parameter of the target, determine the first range of values for the first characteristic parameter of the target;
[0256] The first value range is sent to the aggregation server so that after receiving the first value range and the second value range, the aggregation server determines the target value range and obtains feature binning data based on the target value range. The second value range is the value range of the target second feature parameter sent by the second participant. The target second feature parameter is obtained based on the second sample and the target identical sample. The second sample is the sample in the second parameter data.
[0257] Receive feature-based binning data;
[0258] Based on the feature binning data and the target first parameter square data, the first gradient information is obtained;
[0259] The first gradient information is sent to the model trainer so that the aggregation server can train the federated model based on the first gradient information and the second gradient information. The second gradient information is the gradient information obtained by the second participant based on the feature binning data and the target second parameter data. The target second parameter data is the target second participant data determined from the second participant data based on the first target mask hash value and the second target mask hash value.
[0260] In this embodiment of the application, the first determining module 506 can specifically be used for:
[0261] Based on the first parameter square data of the target, determine the gradient boosting tree, the objective function of the gradient boosting tree, and the first and second derivatives of the objective function. The objective function of the gradient boosting tree is obtained based on the sample label value, which is the label corresponding to the first sample.
[0262] The first gradient information is obtained based on the first and second derivatives of the objective function and the feature binning data.
[0263] Figure 6 This is a structural example diagram of the model building apparatus provided in an embodiment of this application. (See diagram for reference.) Figure 6 As shown, the model building device 60 includes: a first receiving module 601, a second determining module 602, a fifth obtaining module 603, a sending module 604, a first building module 605, and a second building module 606. Wherein:
[0264] The first receiving module 601 is used to receive a first value range of a first target feature parameter sent by a first target participant and a second value range of a second target feature parameter sent by a second target participant, wherein the first target participant and the second target participant are the first participant and the second participant in the sample processing method in the first aspect, and the first target feature parameter and the second target feature parameter are target first participant data obtained according to the sample processing method in the first aspect.
[0265] The second determining module 602 is used to determine the target data range of the target feature parameter based on the first value range of the first target feature parameter and the second value range of the second target feature parameter.
[0266] The fifth module 603 is used to perform feature binning on the target data interval to obtain binned gradient interval data.
[0267] The sending module 604 is used to send binning gradient interval data to the first target participant and the second target participant, so that the first target participant can obtain the first gradient information based on the binning gradient interval data and the first sample data, and send the first gradient information to the model trainer; and the second target participant can obtain the second gradient information based on the binning gradient data and the second sample data, and send the second gradient information to the model trainer.
[0268] The first construction module 605 is used to receive first gradient information and second gradient information, and construct a gradient boosting tree based on the first gradient information and second gradient information;
[0269] The second building module 606 is used to build the target model based on the gradient boosting tree.
[0270] In this embodiment of the application, the second determining module 602 can specifically be used for:
[0271] Determine the first maximum value and the first minimum value within the first value interval;
[0272] Determine the second maximum and second minimum values within the second value interval;
[0273] Based on the first maximum value and the second maximum value, the target maximum value is determined;
[0274] Based on the first minimum value and the second minimum value, the target minimum value is determined;
[0275] Based on the maximum and minimum values of the target, the target data range of the target feature parameters is obtained.
[0276] In this embodiment of the application, the first construction module 605 can be specifically used for:
[0277] Receive the first gradient information and the second gradient information;
[0278] Based on the first gradient information and the second gradient information, the total gradient information of the first target participant and the second target participant is obtained;
[0279] Based on the total gradient information, determine the gain information of each target feature parameter;
[0280] A gradient boosting tree is constructed based on the gain information of each target feature parameter.
[0281] In this embodiment of the application, the first construction module 605 can be specifically used for:
[0282] Determine the target gain value from the gain information of each target feature parameter;
[0283] Based on the target gain value in the gain information of each target feature parameter, determine the split nodes of the gradient boosting tree to be constructed;
[0284] Construct the gradient boosting tree based on the split nodes of the tree to be built.
[0285] In this embodiment of the application, the second construction module 606 can be specifically used for:
[0286] The predicted value for this round is obtained based on the gradient boosting tree;
[0287] Based on the predicted values in this round, the sample label values are updated to obtain the updated sample label values;
[0288] Obtain the iteration number and the prediction value from the previous iteration, which is obtained from the gradient boosting tree of the previous iteration;
[0289] The model loss is obtained based on the previous and current forecast values;
[0290] Based on iteration and model loss, confirm that the initial target model has converged;
[0291] If the initial target model converges, then the initial target model is determined as the target model, and...
[0292] The target model sends data to the first and second participants for short-term charge prediction.
[0293] If the target model does not converge, the updated sample label values are sent to the first and second participants to update the objective function of the gradient boosting tree, as well as the first and second derivatives of the objective function.
[0294] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 7 As shown, the electronic device 70 includes:
[0295] The electronic device 70 may include a processor 701 with one or more processing cores, a memory 702 with one or more computer-readable storage media, a communication component 703, and other components. The processor 701, memory 702, and communication component 703 are connected via a bus 707.
[0296] In the specific implementation process, at least one processor 701 executes computer execution instructions stored in memory 702, causing at least one processor 701 to execute the dictionary construction method and sentiment analysis method as described above.
[0297] The specific implementation process of processor 701 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0298] In the above Figure 7 In the illustrated embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0299] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0300] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0301] In some embodiments, a computer program product is also provided, including a computer program or instructions that, when executed by a processor, implement the steps in any of the above-described sample acquisition methods or model building methods.
[0302] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0303] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A sample acquisition method for power load forecasting, characterized in that, The method, applied to the first participant in a federated model, includes: Obtain first participant data, which includes a first sample and a first feature parameter corresponding to the first sample. The first sample consists of charge data in different rows distinguished by ID, and a power load number corresponding to each row. The first feature parameter refers to the charge generated by a certain power generation method, specifically the charge generated by wind power generation and the charge generated by hydropower generation. There are at least two types of first feature parameters. The first feature parameter corresponding to the first sample is hashed to obtain the hash value of the first feature parameter. The hash value of the first feature parameter is masked to obtain the first mask hash value; The first mask hash value and the second mask hash value are XORed to obtain the target mask hash value. The second mask hash value is obtained by the second participant performing hash processing and mask processing on the second participant data in sequence. The second participant is a participant in the federated model that is different from the first participant. The second participant data includes the second power load sample and the corresponding second power characteristic parameters. Based on the target mask hash value, the hash value of the first feature parameter is masked to obtain the first target mask hash value; Based on the first target mask hash value and the second target mask hash value, target first participant data is determined from the first participant data, wherein the second target mask hash value is the mask hash value obtained by the second participant after masking the hash value of the second feature parameter based on the target mask hash value.
2. The method according to claim 1, characterized in that, The step of masking the hash value of the first feature parameter to obtain the first mask hash value includes: Determine the preset AES encryption function; According to the AES encryption function, the hash value of the first feature parameter is masked to obtain the first mask parameter.
3. The method according to claim 2, characterized in that, The step of determining the target first participant data from the first participant data based on the first target mask hash value and the second target mask hash value includes: Based on the first target mask hash value and the second target mask hash value, determine the same target mask hash value; Based on the hash value of the same target mask, samples with the same target are identified; Based on the target identical samples, a target first sample is determined from the first sample, and a target first feature parameter corresponding to the target first sample is determined, wherein the target first sample is a first sample that is different from the target identical samples; Based on the target first sample and the target first feature parameters, the target first participant data is determined.
4. The method according to claim 1, characterized in that, After determining the target first participant data from the first participant data based on the first target mask hash value and the second target mask hash value, the method further includes: Based on the first feature parameter of the target, determine the first value range of the first feature parameter of the target; The first value range is sent to the model trainer so that after receiving the first value range and the second value range, the model trainer determines the target value range and obtains feature binning data based on the target value range. The second value range is the value range of the target second feature parameter sent by the second participant. The target second feature parameter is obtained based on the second sample and the target identical sample. The second sample is the sample in the data of the second participant. Receive the feature binning data; Based on the feature binning data and the target first participant data, the first gradient information is obtained; The first gradient information is sent to the model trainer so that the model trainer can train the federated model based on the first gradient information and the second gradient information. The second gradient information is the gradient information obtained by the second participant based on the feature binning data and the target second participant data. The target second participant data is determined from the second participant data based on the first target mask hash value and the second target mask hash value.
5. The method according to claim 4, characterized in that, The step of obtaining the first gradient information based on the feature binning data and the target first participant data includes: Based on the target first participant data, the objective function of the gradient boosting tree, as well as the first and second derivatives of the objective function, are determined. The objective function of the gradient boosting tree is obtained based on the sample label value, where the sample label value is the label corresponding to the first sample. The first gradient information is obtained based on the first and second derivatives of the objective function and the feature binning data.
6. A model construction method, characterized in that, Applied to the model training side, the method includes: The method receives a first value range of a first target feature parameter sent by a first target participant and a second value range of a second target feature parameter sent by a second target participant, wherein the first target participant and the second target participant are the first participant and the second participant in the sample acquisition method for power load forecasting as described in claims 1-5, and the first target feature parameter and the second target feature parameter are target first participant data obtained in the sample acquisition method for power load forecasting as described in claims 1-5; and determines the target data range of the target feature parameter based on the first value range of the first target feature parameter and the second value range of the second target feature parameter. The target data range of the target feature parameter is determined based on the first value range of the first target feature parameter and the second value range of the second target feature parameter. The target data interval is subjected to feature binning to obtain binned gradient interval data; The binning gradient interval data is sent to the first target participant and the second target participant, so that the first target participant obtains the first gradient information based on the binning gradient interval data and the first sample data, and sends the first gradient information to the model trainer; and the second target participant obtains the second gradient information based on the binning gradient data and the second sample data, and sends the second gradient information to the model trainer. Receive the first gradient information and the second gradient information, and construct a gradient boosting tree based on the first gradient information and the second gradient information; Construct the target model based on the gradient boosting tree.
7. The method according to claim 6, characterized in that, The step of determining the target data range of the target feature parameter based on the first value range of the first target feature parameter and the second value range of the second target feature parameter includes: Determine the first maximum value and the first minimum value of the first value interval; Determine the second maximum value and the second minimum value within the second value range; Based on the first maximum value and the second maximum value, the target maximum value is determined; Based on the first minimum value and the second minimum value, the target minimum value is determined; The target data range of the target feature parameters is obtained based on the maximum and minimum values of the target.
8. The method according to claim 6, characterized in that, The step of receiving the first gradient information and the second gradient information, and constructing the gradient boosting tree based on the first gradient information and the second gradient information, includes: Receive the first gradient information and the second gradient information; Based on the first gradient information and the second gradient information, the total gradient information of the first target participant and the second target participant is obtained; Based on the total gradient information, the gain information of each of the target feature parameters is determined; The gradient boosting tree is constructed based on the gain information of each of the target feature parameters.
9. The method according to claim 8, characterized in that, The step of constructing the gradient boosting tree based on the gain information of each of the target feature parameters includes: Determine the target gain value in the gain information of each of the target feature parameters; Based on the target gain value in the gain information of each target feature parameter, determine the split nodes of the gradient boosting tree to be constructed; Construct the gradient boosting tree based on the split nodes of the gradient boosting tree to be constructed.
10. The method according to claim 6, characterized in that, The step of constructing the target model based on the gradient boosting tree includes: Based on the gradient boosting tree, the predicted value for this round is obtained; Based on the predicted values for this round, the sample label values are updated to obtain the updated sample label values; Obtain the iteration number and the previous prediction value, which is obtained based on the gradient boosting tree of the previous iteration; The model loss is obtained based on the previous round's prediction value and the current round's prediction value; Based on the number of iterations and the model loss, confirm whether the initial target model has converged; If the initial target model converges, then the initial target model is determined as the target model, and the target model is sent to the first participant and the second participant for short-term charge prediction. If the target model fails to converge, the updated sample label values are sent to the first participant and the second participant to update the objective function of the gradient boosting tree, as well as the first and second derivatives of the objective function.
11. A sample acquisition device for power load forecasting, characterized in that, The device includes: The acquisition module is used to acquire data of the first participant. The data of the first participant includes a first sample and a first feature parameter corresponding to the first sample. The first sample is charge data of different rows distinguished by ID and a power load number corresponding to each row. The first feature parameter refers to the charge generated by a certain power generation method. Specifically, the first feature parameter refers to the charge generated by wind power generation and the charge generated by hydropower generation. There are at least two types of the first feature parameter. The first obtaining module is used to perform hash processing on the first feature parameter corresponding to the first sample to obtain the hash value of the first feature parameter; The second obtaining module is used to perform masking processing on the hash value of the first feature parameter to obtain the first mask hash value; The third module is used to perform an XOR operation on the first mask hash value and the second mask hash value to obtain the target mask hash value. The second mask hash value is obtained by the second participant performing hash processing and mask processing on the second participant data in sequence. The second participant data includes the second power load sample and the corresponding second power characteristic parameters. The fourth module is used to perform masking processing on the hash value of the first feature parameter based on the target mask hash value to obtain the first target mask hash value; The first determining module is used to determine target first participant data from the first participant data based on the first target mask hash value and the second target mask hash value, wherein the second target mask hash value is the mask hash value obtained by the second participant after masking the hash value of the second feature parameter based on the target mask hash value.
12. A model building apparatus, characterized in that, The device includes: The first receiving module is configured to receive a first value range of a first target feature parameter sent by a first target participant and a second value range of a second target feature parameter sent by a second target participant, wherein the first target participant and the second target participant are the first participant and the second participant in the sample acquisition method for power load forecasting as described in claims 1-5, and the first target feature parameter and the second target feature parameter are target first participant data obtained in the sample acquisition method for power load forecasting as described in claims 1-5; The second determining module is used to determine the target data range of the target feature parameter based on the first value range of the first target feature parameter and the second value range of the second target feature parameter. The fifth module is used to perform feature binning processing on the target data interval to obtain binned gradient interval data; The sending module is used to send the binning gradient interval data to the first target participant and the second target participant, so that the first target participant obtains the first gradient information based on the binning gradient interval data and the first sample data, and sends the first gradient information to the model trainer; and the second target participant obtains the second gradient information based on the binning gradient data and the second sample data, and sends the second gradient information to the model trainer. The first construction module is used to receive the first gradient information and the second gradient information, and construct a gradient boosting tree based on the first gradient information and the second gradient information; The second building module is used to build the target model based on the gradient boosting tree.
13. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 10.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1 to 10.
Citation Information
Patent Citations
Methods and systems for improving machines and systems that automate execution of distributed ledger and other transactions in spot and forward markets for energy, compute, storage and other resources
CN112534452A
Federal model training method and device
CN114723068A