Federated learning woe encoding method, apparatus, device, and storage medium
By using an inadvertent transfer protocol and random number matrix exchange in federated learning, WOE encoding is achieved without revealing sample label and feature distribution information, thus solving the security problem of WOE encoding in federated learning and improving data privacy protection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING SHUMU TECH CO LTD
- Filing Date
- 2022-12-26
- Publication Date
- 2026-05-12
AI Technical Summary
In multi-participant federated learning, how can WOE encoding be performed without revealing the distribution information of sample labels and features?
By generating and exchanging a matrix of random numbers and WOE values, and using an unintentional transmission protocol to encode the features in WOE, it is ensured that no party can obtain the real WOE value, and the WOE value is stored in the form of secret fragments.
Secure WOE encoding for federated learning was achieved without disclosing sample labels and feature distribution information, thus improving the security of data privacy protection.
Smart Images

Figure CN116244719B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of data processing technology, and in particular relates to a WOE encoding method, apparatus, device and storage medium for federated learning. Background Technology
[0002] With the development of big data, prioritizing data privacy and security has become a global trend. To achieve collaborative modeling among multiple stakeholders while protecting data privacy and security, Federated Learning has been introduced. In Federated Learning, feature encoding is performed using Weight of Evidence (WOE) values, which reflect the distribution of positive and negative samples.
[0003] In traditional machine learning modeling, the WOE value can be calculated based on the sample's label using formula (1):
[0004]
[0005] Among them, WOE t This represents the WOE value of the t-th bin, Bad. t_sum Bad represents the number of negative samples in the t-th bin. Total Indicates the total number of negative samples in all bins. Good t_sum Good represents the number of positive samples in the t-th bin. Total This indicates the total number of positive samples in all bins.
[0006] However, in multi-participant federated learning, when only one participant has the sample labels and the other participants only have the distribution information of the sample features, how to perform WOE encoding while ensuring that the sample labels and the distribution information of the sample features are not leaked is a problem that urgently needs to be solved. Summary of the Invention
[0007] This application provides a WOE encoding method, apparatus, device, and storage medium for federated learning, which enables WOE encoding in federated learning without disclosing the sample labels or the distribution information of sample features.
[0008] In a first aspect, embodiments of this application provide a federated learning WOE encoding method applied to a first electronic device, the method comprising:
[0009] Obtain a first matrix, wherein the first matrix is a k×m matrix, and the j-th column of the first matrix includes k first WOE values corresponding one-to-one with the k bins of the j-th feature; the k bins of the j-th feature are the k bins obtained by the second electronic device by binning n samples with the j-th feature, where k and n are both integers greater than 1, j is a positive integer less than or equal to m, and m is the number of features of the samples included by the second electronic device;
[0010] Using the first and second matrices, n third matrices are generated, each corresponding to one of the n samples. The second matrix is an n×m matrix, and its j-th column includes n first random numbers corresponding to the j-th feature of each of the n samples. The third matrix is a k×m matrix, and its j-th column includes k second WOE values corresponding to k bins of the j-th feature. The second WOE value corresponding to the t-th bin of the j-th feature is obtained from the first WOE value corresponding to the t-th bin of the j-th feature and the first random number of the j-th feature of the i-th sample. i is an integer less than or equal to n, and t is a natural number less than k.
[0011] Send the n third matrices to the second electronic device;
[0012] Generate a fourth matrix, wherein the fourth matrix is an n×m matrix, and the j-th column of the fourth matrix includes n second random numbers that correspond one-to-one with the j-th feature of the n samples; the second random number corresponding to the j-th feature of the i-th sample is the first random number corresponding to the j-th feature of the i-th sample with the second symbol; the first symbol is the opposite of the second symbol.
[0013] Secondly, embodiments of this application provide a federated learning WOE encoding method applied to a second electronic device, the method comprising:
[0014] The system receives n third matrices sent by the first electronic device, each corresponding to one of the n samples. The third matrix is a k×m matrix, and the j-th column of the third matrix corresponding to the i-th sample includes k second WOE values corresponding to one of the k bins of the j-th feature.
[0015] The second WOE value of the bin corresponding to the j-th feature of the i-th sample is determined as the second WOE value corresponding to the j-th feature of the i-th sample, resulting in a fifth matrix. The fifth matrix is an n×m matrix, and the j-th column of the fifth matrix includes n second WOE values that correspond one-to-one with the j-th feature of the n samples. The bin corresponding to the j-th feature of the i-th sample is the bin in which the i-th sample is located after the second electronic device bins the n samples according to the j-th feature, where i is a positive integer less than or equal to n.
[0016] Thirdly, embodiments of this application provide a WOE encoding apparatus for federated learning, the apparatus comprising:
[0017] The first acquisition module is used to acquire a first matrix, wherein the first matrix is a k×m matrix, and the j-th column of the first matrix includes k first WOE values corresponding one-to-one with the k bins of the j-th feature; the k bins of the j-th feature are the k bins obtained by the second electronic device by binning n samples with the j-th feature, where k and n are both integers greater than 1, j is a positive integer less than or equal to m, and m is the number of features of the samples included by the second electronic device;
[0018] The first generation module is used to generate n third matrices corresponding one-to-one with the n samples using the first matrix and the second matrix. The second matrix is an n×m matrix, and its j-th column includes n first random numbers corresponding one-to-one with the j-th feature of the n samples. The third matrix is a k×m matrix, and its j-th column corresponding to the i-th sample includes k second WOE values corresponding one-to-one with the k bins of the j-th feature. The second WOE value corresponding to the t-th bin of the j-th feature is obtained from the first WOE value corresponding to the t-th bin of the j-th feature and the first random number of the j-th feature of the i-th sample. i is an integer less than or equal to n, and t is a natural number less than k.
[0019] A first transmitting module is used to transmit the n third matrices to the second electronic device;
[0020] The second generation module is used to generate a fourth matrix, wherein the fourth matrix is an n×m matrix, and the j-th column of the fourth matrix includes n second random numbers that correspond one-to-one with the j-th feature of the n samples; the second random number corresponding to the j-th feature of the i-th sample is the first random number corresponding to the j-th feature of the i-th sample with the second symbol; the first symbol is the opposite of the second symbol.
[0021] Fourthly, embodiments of this application provide a WOE encoding apparatus for federated learning, the apparatus comprising:
[0022] The second receiving module is used to receive n third matrices sent by the first electronic device that correspond one-to-one with n samples, wherein the third matrix is a k×m matrix, and the j-th column of the third matrix corresponding to the i-th sample includes k second WOE values that correspond one-to-one with k bins of the j-th feature.
[0023] The second determining module is used to determine the second WOE value of the bin corresponding to the j-th feature of the i-th sample as the second WOE value corresponding to the j-th feature of the i-th sample, thereby obtaining a fifth matrix. The fifth matrix is an n×m matrix, and the j-th column of the fifth matrix includes n second WOE values that correspond one-to-one with the j-th feature of the n samples. The bin corresponding to the j-th feature of the i-th sample is the bin in which the i-th sample is located after the second electronic device bins the n samples according to the j-th feature, where i is a positive integer less than or equal to n.
[0024] Fifthly, embodiments of this application provide a federated learning WOE encoding device, the device comprising: a processor and a memory storing computer program instructions; the processor, when executing the computer program instructions, implements the federated learning WOE encoding method as described in the first or second aspect.
[0025] In a sixth aspect, embodiments of this application provide a computer storage medium storing computer program instructions, which, when executed by a processor, implement the WOE encoding method for federated learning as described in the first or second aspect.
[0026] In a seventh aspect, embodiments of this application provide a computer program product in which instructions, when executed by a processor of an electronic device, cause the electronic device to perform the federated learning WOE encoding method as described in the first or second aspect.
[0027] In this embodiment, when performing WOE encoding on the features of the second electronic device, for the first electronic device with a sample tag, the first WOE values corresponding to the k bins of the j-th feature of the second electronic device (the k bins obtained after binning the n samples with the j-th feature) and the first random numbers corresponding to the j-th features of the n samples can be obtained respectively. Then, for each sample, the second WOE values corresponding to the k bins of the j-th feature can be obtained using the first WOE values corresponding to the k bins of the j-th feature and the first random numbers corresponding to the j-th feature of the sample of the first symbol. This generates n third matrices that correspond one-to-one with the n samples, and sends the n third matrices to the second electronic device. The j-th column of the third matrix corresponding to each sample includes the second WOE values corresponding to the k bins of the j-th feature obtained using the first random numbers corresponding to the j-th feature of the sample. Thus, since the second WOE value is obtained by using the first WOE value and the first random number, the second electronic device cannot obtain the true WOE value of each bin, thereby preventing the second electronic device from deducing the label of each sample in the first electronic device, thus ensuring the security of the label of the sample in the first electronic device.
[0028] For a second electronic device with sample features, after obtaining the second WOE value of each bin, the distribution information of the j-th feature can be used to obtain the second WOE value of the j-th feature of each sample. Thus, since the first electronic device cannot know which bin among the k bins of the j-th feature the second electronic device selects as the second WOE value corresponding to the j-th feature of the sample, the first electronic device cannot deduce the distribution information of the j-th feature in the second electronic device, thereby ensuring the security of the feature distribution information of the samples in the second electronic device.
[0029] Subsequently, the first electronic device can store the second random number corresponding to the j-th feature of each of the n samples, that is, the first random number corresponding to the j-th feature of each of the n samples with the second symbol (opposite to the first symbol). In this way, the true WOE value of the j-th feature of each sample can be converted into the second WOE value and the second random number, and stored in the form of secret fragments in the first electronic device and the second electronic device respectively.
[0030] As can be seen, the embodiments of this application can securely implement WOE encoding of the features of the second electronic device without disclosing the label of the sample of the first electronic device and the distribution information of the features of the sample of the second electronic device, thereby improving the security of WOE encoding in federated learning. Attached Figure Description
[0031] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0032] Figure 1 This is a flowchart of the WOE encoding method for federated learning provided in the embodiments of this application;
[0033] Figure 2 This is a flowchart of the WOE calculation method provided in the embodiments of this application;
[0034] Figure 3 This is an interactive diagram of the WOE calculation process provided in the embodiments of this application;
[0035] Figure 4 This is a schematic diagram of the interaction during the WOE encoding process provided in the embodiments of this application;
[0036] Figure 5 This is one of the structural diagrams of the WOE encoding device for federated learning provided in the embodiments of this application;
[0037] Figure 6 This is the second structural diagram of the WOE encoding device for federated learning provided in the embodiments of this application;
[0038] Figure 7 This is a structural diagram of the WOE encoding device for federated learning provided in the embodiments of this application. Detailed Implementation
[0039] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.
[0040] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.
[0041] In this embodiment, the first electronic device can be a participant in federated learning who has labels on samples; the first electronic device can also be referred to as the label side, client, or client-side. The second electronic device can be a participant in federated learning who has features on samples but does not have labels on samples; the second electronic device can also be referred to as the non-label side, server, or server-side.
[0042] The label of a sample can be used to characterize whether the sample is a positive or negative sample. As an example, if the label of a sample is 0, it means that the sample is a negative sample; if the label of a sample is 1, it means that the sample is a positive sample.
[0043] The first electronic device and the second electronic device can both contain a common set of n samples, where n is an integer greater than 1. The first electronic device acquires the labels of the n samples.
[0044] The second electronic device can have m features for each of the n samples, where m is a positive integer. The second electronic device can bin the n samples using each of the m features, resulting in m binning results for the n samples that correspond one-to-one with the m features.
[0045] Understandably, in practical applications, binning n samples using different features may yield the same or different binning results. Different binning results can specifically manifest in at least one of the following ways: different number of bins; different samples included in each bin.
[0046] For ease of description and understanding, the following description uses the example of a second electronic device binning n samples according to each feature, resulting in k bins. However, this does not limit the number of bins obtained by binning n samples according to each feature to be equal. The k bins obtained by binning n samples according to the j-th feature can be referred to as: the k bins of the j-th feature. It is worth noting that regardless of whether the number of bins obtained by the second electronic device binning n samples according to each feature is equal or unequal, the embodiments of this application can use the same method to perform WOE encoding on each feature of the second electronic device. WOE encoding can also be referred to as: WOE conversion or WOE transcoding.
[0047] Each bin corresponds to a WOE value. The WOE value of each sample in a bin is the WOE value of that bin; that is, for different samples in a bin, their corresponding WOE values are equal. Since the second electronic device bins the n samples by features, the WOE value of each sample in the t-th bin of the k-th bins of the j-th feature is: the WOE value of the sample corresponding to the j-th feature.
[0048] In the above description, i can be a positive integer less than or equal to n, meaning the sample number can start from 1; j can be a positive integer less than or equal to m, meaning the feature number can start from 1; t can be a natural number less than k, meaning the feature number can start from 0. It is understood that the embodiments of this application do not limit the starting numbers of samples, features, and bins, and these can be determined according to actual circumstances. The embodiments of this application do not impose any limitations on this.
[0049] In this embodiment, WOE encoding of features can be achieved based on Oblivious Transfer (OT). Specifically, by using the Oblivious Transfer protocol, when encoding the features of the second electronic device using WOE, the WOE values corresponding to each feature of each sample are converted into pairs of data and stored as secret fragments in the first and second electronic devices respectively for subsequent modeling stages. For example, the WOE value corresponding to the j-th feature of the i-th sample, i.e., the WOE... i,j It can be converted to: WOE i,j,Client and WOE i,j,Server WOE i,j,Client Stored in the first electronic device, WOE i,j,Server Stored in a second electronic device.
[0050] The WOE encoding method for federated learning provided in this application will be described in detail below with reference to the accompanying drawings, through some embodiments and application scenarios.
[0051] See Figure 1 , Figure 1 This is a flowchart of the WOE encoding method for federated learning provided in this application embodiment. For example... Figure 1 As shown, the WOE encoding method for federated learning may include the following steps:
[0052] Step 101: The first electronic device acquires the first matrix.
[0053] Wherein, the first matrix is a k×m matrix, and the j-th column of the first matrix includes k first WOE values that correspond one-to-one with the k bins of the j-th feature; the k bins of the j-th feature are the k bins obtained by the second electronic device by binning the n samples with the j-th feature, where k and n are both integers greater than 1, j is a positive integer less than or equal to m, and m is the number of features of the samples included in the second electronic device.
[0054] The first matrix includes the true WOE values of each bin of the second electronic device. Specifically, the j-th column of the first matrix includes the true WOE values of the k bins obtained by the second electronic device binning the n samples with the j-th feature, which are the first WOE values. Therefore, assuming that the second electronic device bins the n samples with each feature and obtains k bins, the first matrix is a k×m matrix.
[0055] The embodiments of this application do not limit the method by which the first electronic device obtains the true WOE values of each compartment of the second electronic device. Any method that enables the first electronic device to obtain the true WOE values of each compartment of the second electronic device can fall within the protection scope of the embodiments of this application.
[0056] As an example, suppose the first WOE value of the j-th column of the first matrix is as shown in Table 1.
[0057] Table 1: WOE value of the first column of the first matrix
[0058] Packing Number First WOE value 0 WOE j,0 ]]> 1 WOE j,1 ]]> 2 WOE j,2 ]]> ... ... k-1 WOE j,k-1 ]]>
[0059] Step 102: The first electronic device uses the first matrix and the second matrix to generate n third matrices that correspond one-to-one with the n samples.
[0060] Wherein, the second matrix is an n×m matrix, and the j-th column of the second matrix includes n first random numbers corresponding one-to-one with the j-th feature of the n samples; the third matrix is a k×m matrix, and the j-th column of the third matrix corresponding to the i-th sample includes k second WOE values corresponding one-to-one with the k bins of the j-th feature, and the second WOE value corresponding to the t-th bin of the j-th feature is obtained from the first WOE value corresponding to the t-th bin of the j-th feature and the first random number of the j-th feature of the i-th sample of the first symbol; i is an integer less than or equal to n, and t is a natural number less than k.
[0061] To ensure that the labels of the samples from the first electronic device are not disclosed, the first electronic device can generate a random number for each feature of each sample before executing step 102, i.e., a first random number. Then, the first random number corresponding to each feature of each sample can be used to generate a second matrix. The j-th column of the second matrix includes the first random numbers corresponding to the j-th features of the n samples. Therefore, the second matrix is an n×m matrix.
[0062] After acquiring the first and second matrices, the first electronic device can obtain the third matrix corresponding to each sample, on a sample-by-sample basis. The j-th column of the third matrix corresponding to the i-th sample may include: the first WOE value corresponding to the k bins of the j-th feature, and the first random number corresponding to the j-th feature of the i-th sample of the first symbol. Therefore, the third matrix is a k×m matrix.
[0063] Understandably, the second WOE value in the same column of the third matrix corresponding to the i-th sample is obtained by processing the same first random number. For example, the second WOE value in the j-th column of the third matrix corresponding to the i-th sample is obtained by processing the first random number corresponding to the j-th feature of the i-th sample. Thus, even if the first electronic device cannot know which bin the i-th sample belongs to after the second electronic device bins the n samples according to each feature, the first electronic device can know the first random number used to reconstruct the true WOE values of each feature of the i-th sample, thereby improving the reliability of WOE encoding.
[0064] For ease of understanding, the following example illustrates the generation of the third matrix corresponding to the i-th sample. It can be understood that the third matrix corresponding to other samples can be generated in the same way.
[0065] The second WOE value corresponding to the t-th bin of the j-th feature can be generated by the first WOE value corresponding to the t-th bin of the j-th feature and the first random number corresponding to the j-th feature of the i-th sample of the first symbol. The first symbol can be a plus sign (+), a minus sign (-), a multiplication sign (×), or a division sign ( / ), which can be determined according to actual needs. This application embodiment does not limit this.
[0066] When the first symbol is represented by a plus sign (+), the second WOE value corresponding to the t-th bin of the j-th feature is equal to the first WOE value corresponding to the t-th bin of the j-th feature plus the first random number corresponding to the j-th feature of the i-th sample.
[0067] When the first symbol is represented by a minus sign (-), the second WOE value corresponding to the t-th bin of the j-th feature is equal to the first WOE value corresponding to the t-th bin of the j-th feature minus the first random number corresponding to the j-th feature of the i-th sample.
[0068] When the first symbol is represented by a multiplication sign (×), the second WOE value corresponding to the t-th bin of the j-th feature is equal to the first WOE value corresponding to the t-th bin of the j-th feature × the first random number corresponding to the j-th feature of the i-th sample.
[0069] When the first symbol is represented by a division sign ( / ), the second WOE value corresponding to the t-th bin of the j-th feature is equal to the first WOE value corresponding to the t-th bin of the j-th feature / the first random number corresponding to the j-th feature of the i-th sample.
[0070] It can be seen that the second WOE value corresponding to the t-th bin of the j-th feature can be obtained by concatenating the first WOE value corresponding to the t-th bin of the j-th feature and the first random number corresponding to the j-th feature of the i-th sample of the first symbol, and the first random number of the first symbol is located after the first WOE value. The first symbol can be understood as the operator between the first WOE value and the first random number.
[0071] As an example, assuming the first symbol is a plus sign (+), the second WOE value of the j-th column of the third matrix is shown in Table 2.
[0072] Table 2: Second WOE value of the j-th column of the third matrix
[0073] Packing Number Second WOE value 0 <![CDATA[WOE j,0 +r j ]]> 1 <![CDATA[WOE j,1 +r j ]]> 2 <![CDATA[WOE j,2 +r j ]]> ... ... k-1 <![CDATA[WOE j,k-1 +r j ]]>
[0074] r in Table 2 j Let r represent the random number corresponding to the j-th feature. It is worth noting that Table 2 can be applied to the third matrix corresponding to any sample; for the third matrix corresponding to the i-th sample, r... j This represents the random number corresponding to the j-th feature of the i-th sample.
[0075] Step 103: The first electronic device sends the n third matrices to the second electronic device.
[0076] Correspondingly, the second electronic device receives the n third matrices sent by the first electronic device, each corresponding to one of the n samples.
[0077] Since the second WOE value is obtained by using the first WOE value and the first random number, the second electronic device cannot obtain the true WOE value of each bin, thus preventing the second electronic device from deducing the label of each sample in the first electronic device, thereby ensuring the security of the label of the sample in the first electronic device.
[0078] Step 104: The second electronic device determines the second WOE value of the bin corresponding to the j-th feature of the i-th sample as the second WOE value corresponding to the j-th feature of the i-th sample, and obtains the fifth matrix.
[0079] Wherein, the fifth matrix is an n×m matrix, and the j-th column of the fifth matrix includes n second WOE values that correspond one-to-one with the j-th feature of the n samples; the binning of the j-th feature corresponding to the i-th sample is the binning in which the i-th sample is located after the second electronic device bins the n samples with the j-th feature, where i is a positive integer less than or equal to n.
[0080] Since the second electronic device knows the samples included in each bin, after obtaining the third matrix corresponding to the i-th sample, the second electronic device can obtain the second WOE value corresponding to each feature of the i-th sample based on the third matrix corresponding to the i-th sample.
[0081] Taking the i-th sample and the j-th feature as an example, the second electronic device can first determine the bin of the j-th feature corresponding to the i-th sample, that is, determine which bin the i-th sample belongs to among the k bins of the j-th feature. Then, the second WOE value corresponding to that bin can be determined as the second WOE value corresponding to the j-th feature of the i-th sample.
[0082] After obtaining the second WOE value corresponding to each feature of each sample, the second WOE value corresponding to each feature of each sample can be used to generate the fifth matrix. The j-th column of the fifth matrix includes the second WOE value corresponding to the j-th feature of each of the n samples. Therefore, the fifth matrix is an n×m matrix.
[0083] Thus, since the first electronic device cannot know which bin among the k bins of the j-th feature selected by the second electronic device corresponds to the second WOE value as the second WOE value corresponding to the j-th feature of the sample, the first electronic device cannot deduce the distribution information of the j-th feature in the second electronic device, thereby ensuring the security of the feature distribution information of the sample in the second electronic device.
[0084] As an example, suppose there are 13 samples instead of n samples. After binning the 13 samples according to the j-th feature, the binning of the 13 samples is shown in Table 3. Then, the second WOE value of the 13 samples is shown in Table 4.
[0085] Table 3: Binning corresponding to the j-th feature of the 13 samples
[0086] Sample Index Packing Number 1 0 2 0 3 1 4 2 5 2 ... ... 11 k-1 12 k-1 13 k-1
[0087] Table 4: Third WOE value corresponding to the j-th column of the fifth matrix
[0088] Sample index Packing Number Second WOE value 1 0 <![CDATA[WOE j,0 +r 1,j ]]> 2 0 <![CDATA[WOE j,0 +r 2,j ]]> 3 1 <![CDATA[WOE j,1 +r 3,j ]]> 4 2 <![CDATA[WOE j,2 +r 4,j ]]> 5 2 <![CDATA[WOE j,2 +r 5,j ]]> ... ... ... 11 k-1 <![CDATA[WOE j,k-1 +r 11,j ]]> 12 k-1 <![CDATA[WOE j,k-1 +r 12,j ]]> 13 k-1 <![CDATA[WOE j,k-1 +r 13,j ]]>
[0089] In Table 4, WOE j,t r represents the first WOE value corresponding to the t-th bin of the j-th feature. i,jThis represents the first random number corresponding to the j-th feature of the i-th sample.
[0090] Step 105: The first electronic device generates the fourth matrix.
[0091] Wherein, the fourth matrix is an n×m matrix, and the j-th column of the fourth matrix includes n second random numbers that correspond one-to-one with the j-th feature of the n samples; the second random number corresponding to the j-th feature of the i-th sample is the first random number corresponding to the j-th feature of the i-th sample with the second symbol; the first symbol is the opposite of the second symbol.
[0092] After generating the third matrix using the second matrix, the first electronic device can generate the fourth matrix using the generation method of the third matrix and the second matrix. The j-th column of the fourth matrix includes the second random number corresponding to the j-th feature of each of the n samples; therefore, the fourth matrix is an n×m matrix.
[0093] The second symbol can be a plus sign (+), a minus sign (-), a multiplication sign (×), or a division sign ( / ), depending on the first symbol. The second symbol is the opposite of the first symbol.
[0094] Specifically, when the first sign is a plus sign (+), the second sign is a minus sign (-). When the first sign is a minus sign (-), the second sign is a minus sign (-). When the first sign is a multiplication sign (×), the second sign is a division sign ( / ). When the first sign is a division sign ( / ), the second sign is a multiplication sign (×).
[0095] As an example, when the first sign is a plus sign (+) and the second sign is a minus sign (-), the second WOE value corresponding to the t-th bin of the j-th feature is the sum of the first WOE value corresponding to the t-th bin of the j-th feature and the first random number of the j-th feature of the i-th sample; the second random number corresponding to the j-th feature of the i-th sample is the first random number ri corresponding to the j-th feature of the i-th sample. j The negative number, i.e., -r i,j If the second WOE value corresponding to the t-th bin of the j-th feature is: the difference between the first WOE value corresponding to the t-th bin of the j-th feature and the first random number of the j-th feature of the i-th sample; then the second random number corresponding to the j-th feature of the i-th sample is: r i,j In this case, the fourth matrix is the same as the second matrix.
[0096] If the second WOE value corresponding to the t-th bin of the j-th feature is: the product of the first WOE value corresponding to the t-th bin of the j-th feature and the first random number of the j-th feature of the i-th sample; and the second random number corresponding to the j-th feature of the i-th sample is: / ri,j .
[0097] If the second WOE value corresponding to the t-th bin of the j-th feature is: the quotient of the first WOE value corresponding to the t-th bin of the j-th feature divided by the first random number of the j-th feature of the i-th sample; the second random number corresponding to the j-th feature of the i-th sample is: ×r i,j .
[0098] It should be noted that the execution order of steps 103 and 105 is not limited in the embodiments of this application.
[0099] After generating the fourth matrix, the first electronic device can save it; similarly, after generating the fifth matrix, the second electronic device can save it. This allows the true WOE values corresponding to each feature of each sample to be stored as secret fragments in the first and second electronic devices respectively. In this way, the seventh and eighth matrices can be used for the subsequent modeling stage of federated learning. In the subsequent modeling stage, the seventh and eighth matrices can be used to obtain the true WOE values corresponding to each feature of each sample in the second electronic device.
[0100] In the embodiments of this application, WOE i,j,Client The second WOE value corresponding to the j-th feature of the i-th sample is represented by the WOE value. i,j,Server It is represented as the second random number corresponding to the j-th feature of the i-th sample.
[0101] Assumption: The second WOE value corresponding to the j-th feature of the i-th sample is WOE. j,i,new .
[0102] When the first sign is a plus sign (+) and the second sign is a minus sign (-), WOE can be calculated using formula (2). i,j :
[0103] WOE i,j =WOE j,i,new -r i,j (2)
[0104] In formula (2), WOE j,i,new For WOE i,j,Client , -r i,j For WOE i,j,Server .
[0105] When the first sign is a minus sign (-) and the second sign is a plus sign (+), WOE can be calculated using formula (3). i,j :
[0106] WOE i,j =WOE j,i,new +r i,j(3)
[0107] In formula (3), WOE j,i,new For WOE i,j,Client +r i,j For WOE i,j,Server .
[0108] When the first sign is a multiplication sign (×) and the second sign is a division sign ( / ), WOE can be calculated using formula (4). i,j :
[0109] WOE i,j =WOE j,i,new / r i,j (4)
[0110] In formula (4), WOE j,i,new For WOE i,j,Client , / r i,j For WOE i,j,Server .
[0111] When the first sign is a division sign ( / ) and the second sign is a multiplication sign (×), WOE can be calculated using formula (5). i,j :
[0112] WOE i,j =WOE j,i,new ×r i,j (5)
[0113] In formula (5), WOE j,i,new For WOE i,j,Client , ×r i,j For WOE i,j,Server .
[0114] It can be seen that the true WOE value corresponding to the j-th feature of the i-th sample can be calculated by concatenating the second WOE value corresponding to the j-th feature of the i-th sample with a second random number, where the second random number follows the second WOE value. The second sign can be understood as an operation symbol between the second WOE value and the first random number. When the first sign is a plus sign (+) or a minus sign (-), the WOE... i,j The calculation formula can be equivalent to formula (6):
[0115] WOE i,j =WOE i,j,Client +WOE i,j,Server (6)
[0116] It is evident that the first electronic device and the second electronic device can securely implement WOE encoding of the features of the second electronic device without disclosing the label of the sample of the first electronic device or the distribution information of the features of the sample of the second electronic device, thereby ensuring the security of WOE encoding in federated learning.
[0117] The federated learning WOE encoding method of this application embodiment, when encoding the features of a second electronic device using WOE, for a first electronic device with a sample label, can first obtain the first WOE values corresponding to the k bins of the j-th feature of the second electronic device (the k bins obtained after binning the n samples with the j-th feature), and the first random numbers corresponding to the j-th features of the n samples. Then, for each sample, the first WOE values corresponding to the k bins of the j-th feature, and the first random numbers corresponding to the j-th feature of the sample, can be used to obtain the second WOE values corresponding to the k bins of the j-th feature. This generates n third matrices that correspond one-to-one with the n samples, and sends the n third matrices to the second electronic device. The j-th column of each sample's third matrix includes the second WOE values corresponding to the k bins of the j-th feature obtained using the first random numbers corresponding to the j-th feature of that sample. Thus, since the second WOE value is obtained by using the first WOE value and the first random number, the second electronic device cannot obtain the true WOE value of each bin, thereby preventing the second electronic device from deducing the label of each sample in the first electronic device, thus ensuring the security of the label of the sample in the first electronic device.
[0118] For a second electronic device with sample features, after obtaining the second WOE value of each bin, the distribution information of the j-th feature can be used to obtain the second WOE value of the j-th feature of each sample. Thus, since the first electronic device cannot know which bin among the k bins of the j-th feature the second electronic device selects as the second WOE value corresponding to the j-th feature of the sample, the first electronic device cannot deduce the distribution information of the j-th feature in the second electronic device, thereby ensuring the security of the feature distribution information of the samples in the second electronic device.
[0119] Subsequently, the first electronic device can store the second random number corresponding to the j-th feature of each of the n samples, that is, the first random number corresponding to the j-th feature of each of the n samples with the second symbol (opposite to the first symbol). In this way, the true WOE value of the j-th feature of each sample can be converted into the second WOE value and the second random number, and stored in the form of secret fragments in the first electronic device and the second electronic device respectively.
[0120] As can be seen, the embodiments of this application can securely implement WOE encoding of the features of the second electronic device without disclosing the label of the sample of the first electronic device and the distribution information of the features of the sample of the second electronic device, thereby improving the security of WOE encoding in federated learning.
[0121] The following explains how the first electronic device obtains the true WOE values of each sub-bin of each feature of the second electronic device.
[0122] In this embodiment, the WOE calculation of features can be achieved based on homomorphic encryption. That is, homomorphic encryption technology can be used to calculate the true WOE value of each sub-bin of each feature of the second electronic device by the first electronic device.
[0123] In practical implementation, a semi-homomorphic encryption scheme (such as Paillier, OU, etc.) can be used to calculate the Word of Encryption (WOE) of the characteristics of the second electronic device. The specific implementation can be determined according to the actual situation, and this application does not limit this. In the embodiments of this application, through... This indicates homomorphic encryption.
[0124] like Figure 2 As shown, the WOE calculation method may include the following steps:
[0125] Step 200: Generate a key pair, which includes a public key and a private key.
[0126] Step 201: The first electronic device uses the public key to encrypt the first column vector to obtain the second column vector.
[0127] The first column vector includes n first labels corresponding to each of the n samples, and the second column vector includes n second labels corresponding to each of the n samples.
[0128] In this embodiment, the first electronic device has tags corresponding to each of the n samples. The first electronic device can use the tags corresponding to the n samples to generate a first column vector.
[0129] To prevent the leakage of sample labels, the first electronic device can use a public key to homomorphically encrypt the first column vector to obtain the second vector and execute step 202.
[0130] Step 202: The first electronic device sends the public key and the second column vector to the second electronic device.
[0131] Accordingly, the second electronic device receives the public key and the second column vector sent by the first electronic device.
[0132] Since the labels in the second column vector are encrypted values, the second electronic device cannot obtain the labels of each sample, thus ensuring the security of the labels of the samples in the first electronic device.
[0133] Step 203: The second electronic device uses the second labels corresponding to each sample in the t-th bin of the j-th feature to determine the number of positive samples and the number of negative samples in the t-th bin of the j-th feature, and obtains the number of positive samples and the number of negative samples in the k bins of the j-th feature, where t is a natural number less than k.
[0134] In this embodiment, the second electronic device automatically bins the n samples using the j-th feature. Therefore, the second electronic device knows the samples included in each bin of the j-th feature. Based on this, the second electronic device can use the second label corresponding to each sample in each bin of the j-th feature to calculate the number of positive samples and the number of negative samples in each bin of the j-th feature.
[0135] The embodiments of this application do not limit the method of determining the number of positive and negative samples in each bin. Any method that can use the second label to determine the number of positive and negative samples in a bin can fall within the protection scope of the embodiments of this application.
[0136] In some embodiments, determining the number of positive and negative samples in the t-th bin of the j-th feature using the second labels corresponding to each sample in the t-th bin of the j-th feature may include:
[0137] The sum of the second labels corresponding to each sample in the t-th bin of the j-th feature is determined as the number of negative samples in the t-th bin of the j-th feature;
[0138] Subtract the number of negative samples in the t-th bin of the j-th feature from the target value to obtain the number of positive samples in the t-th bin of the j-th feature, where the target value is the number of samples included in the t-th bin of the j-th feature.
[0139] In this embodiment, the number of negative samples Bad for the t-th bin of the j-th feature can be calculated using formula (7). t_sum The number of positive samples in the t-th bin for the j-th feature is calculated using formula (8). t_sum .
[0140] Bad t_sum = sum(bin t) (7)
[0141] Good t_sum = count(bin t) - Bad t_sum (8)
[0142] Where sum(bint t) represents the sum of the second labels of all samples in bint t. count(bint t) represents the number of samples in bint t.
[0143] Step 204: The second electronic device uses the public key to encrypt the number of the k sub-boxes of the j-th feature, as well as the number of positive and negative samples of the k sub-boxes of the j-th feature.
[0144] To prevent the leakage of the distribution information of features in the second electronic device, the second electronic device can use the public key to homomorphically encrypt the number of each sub-box, the number of positive samples, and the number of negative samples, and then execute step 205.
[0145] Step 205: The second electronic device sends target information to the first electronic device. The target information includes the encrypted number of the k bins of the j-th feature, and the number of positive and negative samples of the k bins of the j-th feature.
[0146] Accordingly, the first electronic device receives the target information sent by the second electronic device.
[0147] Since the number, number of positive samples, and number of negative samples of each sub-box are all encrypted values, the first electronic device cannot deduce the actual number of positive and negative samples of each sub-box in the second electronic device, as well as the specific number corresponding to each sub-box, thereby ensuring the security of the distribution information of the sample characteristics in the second electronic device.
[0148] Step 206: The first electronic device decrypts the target information using the private key.
[0149] Based on the characteristics of homomorphic encryption, the first electronic device can use the private key to decrypt and obtain the number of each sub-box, the number of positive samples, and the number of negative samples.
[0150] Step 207: The first electronic device uses the number of positive and negative samples of the k bins of the decrypted j-th feature to determine the k first WOE values that correspond one-to-one with the k bins of the j-th feature.
[0151] In practice, for each sub-box, the first WOE value corresponding to each sub-box can be calculated using formula (1) or formula (9).
[0152] WOE t =ln(Bad t_sum / Bad Total )-ln(Good t_sum Good Total (9)
[0153] As can be seen, the embodiments of this application can securely perform WOE calculation of the features of the second electronic device without disclosing the label of the sample of the first electronic device and the distribution information of the features of the sample of the second electronic device, thereby improving the security of WOE calculation in federated learning.
[0154] It should be noted that the various optional implementation methods described in the embodiments of this application can be combined with each other or implemented individually without conflict, and the embodiments of this application do not limit this.
[0155] For ease of understanding, the following example is provided:
[0156] I. WOE computation based on semi-homomorphic encryption.
[0157] In this embodiment, homomorphic encryption technology can be used to calculate the WOE value for multiple participants. Using this method, the WOE value can be calculated jointly without the Client exposing tag information or the Server exposing feature distribution information. The specific calculation process is as follows:
[0158] Step 1: The Client generates a public-private key pair and sends the public key to the Server.
[0159] In practice, the client can use the Paillier semi-homomorphic encryption algorithm to generate a public-private key pair, keep the private key, and send the public key to the server.
[0160] Step 2: The server receives the client's public key.
[0161] Step 3: The Client encrypts the tag column using a public key to form a tag vector, and then sends the tag vector to the Server.
[0162] In practice, the client can use the public key to homomorphically encrypt the sample's tags 0 and 1, forming a tag homomorphic encryption vector, which is then sent to the server. For example... Figure 3 As shown.
[0163] Step 4: The server receives the tag vector sent by the client, sums the tags within each bin based on its own feature binning and the client's sample index. After summing, the server encrypts the binning tag summation result using the public key and sends it to the client.
[0164] The server receives the sample tag vector sent by the client and, based on its own sample binning information, performs the following calculations on the encrypted vector within each bin:
[0165] Bad t_sum= sum(bins t)
[0166] Good t_sum = count(bins t) - Bad t_sum
[0167] The server uses a public key to encrypt the box number and Bad. t_sum With Good t_sum And send it to the Client.
[0168] Step 5: The Client decrypts the results and calculates the WOE value of the bins based on the sum of good and bad samples from its own sample.
[0169] The client receives the bin number t sent by the server, Bad. t_sum With Good t_sum The information is decrypted, and the Bad code is calculated. Total With Good Total Calculate the WOE value for different bins t: ln(Bad t_sum / Bad Total )-ln(Good t_sum Good Total Finally, the WOE value corresponding to the binning of this feature is obtained.
[0170] Based on the above WOE calculation process, it is possible to calculate the WOE value of both parties without revealing the client-side tag information or the distribution of server-side features.
[0171] II. WOE encoding based on unintentional transmission.
[0172] In this embodiment, the WOE value corresponding to the feature of each sample can be stored as a secret fragment on both the Client and Server sides through unintentional transmission for use in the subsequent modeling stage.
[0173] By using inadvertent transmission technology, when performing WOE transformation on the features on the server side, the WOE value of each feature for each sample can be converted into a secretly shared pair of data (WOE). i,j,Client and WOE i,j,Server ), where i = 1, 2, ..., n (n is the number of samples), j = 1, 2, ..., m (m is the number of features on the server side), and in some embodiments, the following can be satisfied:
[0174] WOE i,j =WOE i,j,Client +WOE i,j,Server
[0175] The client side has WOE values, and the server has binning information with corresponding characteristics.
[0176] like Figure 4 As shown, the WOE transcoding process is as follows:
[0177] Step 1: The Client generates a random number for each sample and each feature, forming a random matrix n x m, where n is the number of samples and m is the number of sample features included in the Server. For the i-th sample, the Client adds the WOE value of each feature's bin to the first random number of each feature of the i-th sample, forming n k x m matrices (n is the number of samples). This matrix group is then sent to the Server.
[0178] Step 2: On the server side, the bin index is used as the selection signal. Based on the bin index of the sample, the WOE value is selected in k-to-k (1 to k) selection.
[0179] Step 3: The client side saves the random number matrix, and the server side saves the corresponding selected WOE value.
[0180] exist Figure 4 Let's take a sample and its j-th feature as an example. Running a 1-to-k OT protocol, the Client, acting as the sender, inputs the second WOE value corresponding to the k bins of the j-th feature. The Server, acting as the receiver, inputs the bin number t to which the sample belongs. Thus, the Server can obtain the second WOE value of the j-th feature of the sample: WOE j,t +r, but the Client side cannot obtain the second WOE value of the j-th feature of the sample, and the output of the Client side is: Unknown (NA).
[0181] In scenarios where a large number of 1-to-k OT protocols need to be run, OT extension or silent OT technologies can be used to improve the execution efficiency of OT protocols.
[0182] Based on the above WOE transcoding process, the client side will not expose tag information, and the server side will not expose binning information of feature data, thus securely realizing feature WOE transcoding.
[0183] Based on the WOE encoding method for federated learning provided in the above embodiments, this application also provides specific implementations of a WOE encoding device for federated learning. Please refer to the following embodiments.
[0184] like Figure 5 The WOE encoding device 500 for federated learning provided in this application embodiment may include:
[0185] The first acquisition module 501 is used to acquire a first matrix, wherein the first matrix is a k×m matrix, and the j-th column of the first matrix includes k first WOE values corresponding one-to-one with the k bins of the j-th feature; the k bins of the j-th feature are the k bins obtained by the second electronic device by binning n samples with the j-th feature, where k and n are both integers greater than 1, j is a positive integer less than or equal to m, and m is the number of features of the samples included by the second electronic device;
[0186] The first generation module 502 is used to generate n third matrices corresponding one-to-one with the n samples using the first matrix and the second matrix. The second matrix is an n×m matrix, and its j-th column includes n first random numbers corresponding one-to-one with the j-th feature of the n samples. The third matrix is a k×m matrix, and its j-th column corresponding to the i-th sample includes k second WOE values corresponding one-to-one with the k bins of the j-th feature. The second WOE value corresponding to the t-th bin of the j-th feature is obtained from the first WOE value corresponding to the t-th bin of the j-th feature and the first random number of the j-th feature of the i-th sample. i is an integer less than or equal to n, and t is a natural number less than k.
[0187] The first transmitting module 503 is used to transmit the n third matrices to the second electronic device;
[0188] The second generation module 504 is used to generate a fourth matrix, wherein the fourth matrix is an n×m matrix, and the j-th column of the fourth matrix includes n second random numbers that correspond one-to-one with the j-th feature of the n samples; the second random number corresponding to the j-th feature of the i-th sample is the first random number corresponding to the j-th feature of the i-th sample with the second symbol; the first symbol is the opposite of the second symbol.
[0189] In some embodiments, the second WOE value corresponding to the t-th bin of the j-th feature is the sum of the first WOE value corresponding to the t-th bin of the j-th feature and the first random number of the j-th feature of the i-th sample;
[0190] The second random number corresponding to the j-th feature of the i-th sample is the negative of the first random number corresponding to the j-th feature of the i-th sample.
[0191] In some embodiments, the apparatus further includes:
[0192] The third generation module is used to generate key pairs, which include a public key and a private key;
[0193] The first encryption module is used to encrypt the first column vector using the public key to obtain the second column vector, wherein the first column vector includes n first tags corresponding one-to-one with the n samples, and the second column vector includes n second tags corresponding one-to-one with the n samples;
[0194] The second sending module is used to send the public key and the second column vector to the second electronic device;
[0195] The first receiving module is used to receive target information sent by the second electronic device. The target information includes the encrypted number of the k sub-bins of the j-th feature, and the number of positive samples and the number of negative samples of the k sub-bins of the j-th feature.
[0196] The first decryption module is used to decrypt the target information using the private key;
[0197] The first determining module is used to determine the k first WOE values corresponding one-to-one with the k bins of the j-th feature by using the number of positive and negative samples of the k bins of the decrypted j-th feature.
[0198] The federated learning WOE encoding device 500 provided in this application embodiment can implement the various processes implemented by the first electronic device in the method embodiment, and will not be described again here to avoid repetition.
[0199] like Figure 6 The WOE encoding device 600 for federated learning provided in this application embodiment may include:
[0200] The second receiving module 601 is used to receive n third matrices sent by the first electronic device that correspond one-to-one with n samples, wherein the third matrix is a k×m matrix, and the j-th column of the third matrix corresponding to the i-th sample includes k second WOE values that correspond one-to-one with k bins of the j-th feature.
[0201] The second determining module 602 is used to determine the second WOE value of the bin corresponding to the j-th feature of the i-th sample as the second WOE value corresponding to the j-th feature of the i-th sample, and obtain a fifth matrix, wherein the fifth matrix is an n×m matrix, and the j-th column of the fifth matrix includes n second WOE values that correspond one-to-one with the j-th feature of the n samples; the bin corresponding to the j-th feature of the i-th sample is the bin in which the i-th sample is located after the second electronic device bins the n samples with the j-th feature, where i is a positive integer less than or equal to n.
[0202] In some embodiments, the apparatus further includes:
[0203] The third receiving module is used to receive the public key and the second column vector sent by the first electronic device, wherein the second column vector includes n second tags that correspond one-to-one with the n samples;
[0204] The third determining module is used to determine the number of positive samples and the number of negative samples in the t-th bin of the j-th feature by using the second labels corresponding to each sample in the t-th bin of the j-th feature, and to obtain the number of positive samples and the number of negative samples in the k bins of the j-th feature, where t is a natural number less than k.
[0205] The second encryption module is used to encrypt the number of the k sub-boxes of the j-th feature, as well as the number of positive and negative samples of the k sub-boxes of the j-th feature using the public key;
[0206] The third sending module is used to send target information to the first electronic device. The target information includes the encrypted number of the k sub-boxes of the j-th feature, as well as the number of positive samples and the number of negative samples of the k sub-boxes of the j-th feature.
[0207] In some embodiments, the third determining module includes:
[0208] The first determining unit is used to determine the sum of the second labels corresponding to each sample in the t-th bin of the j-th feature as the number of negative samples in the t-th bin of the j-th feature;
[0209] The second determining unit is used to subtract the number of negative samples in the t-th bin of the j-th feature from the target value to obtain the number of positive samples in the t-th bin of the j-th feature, wherein the target value is the number of samples included in the t-th bin of the j-th feature.
[0210] The federated learning WOE encoding device 600 provided in this application embodiment can implement the various processes implemented by the first electronic device in the method embodiment, and will not be described again here to avoid repetition.
[0211] Figure 7 The diagram shows the hardware structure of the WOE encoding for federated learning provided in this application embodiment.
[0212] The WOE encoding device in federated learning may include a processor 701 and a memory 702 storing computer program instructions.
[0213] Specifically, the processor 701 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0214] Memory 702 may include mass storage for data or instructions. For example, and not limitingly, memory 702 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 702 may include removable or non-removable (or fixed) media. Where appropriate, memory 702 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 702 is non-volatile solid-state memory.
[0215] Memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Therefore, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this disclosure.
[0216] The processor 701 implements any of the federated learning WOE encoding methods in the above embodiments by reading and executing computer program instructions stored in the memory 702.
[0217] In one example, the federated learning WOE encoding device may also include a communication interface 707 and a bus 710. For example, Figure 7 As shown, the processor 701, memory 702, and communication interface 707 are connected through bus 710 and complete communication with each other.
[0218] The communication interface 707 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0219] Bus 710 includes hardware, software, or both, that couples components of a federated learning WOE encoding device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 710 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.
[0220] Furthermore, in conjunction with the WOE encoding method for federated learning in the above embodiments, this application embodiment can provide a computer storage medium for implementation. This computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the WOE encoding methods for federated learning in the above embodiments.
[0221] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0222] The functional blocks shown in the above-described structural diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0223] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0224] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0225] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A federated learning WOE coding method, applied to a first electronic device, characterized in that, include: Obtain a first matrix, wherein the first matrix is a k×m matrix, and the j-th column of the first matrix includes k first WOE values corresponding one-to-one with the k bins of the j-th feature; the k bins of the j-th feature are the k bins obtained by the second electronic device by binning n samples with the j-th feature, where k and n are both integers greater than 1, j is a positive integer less than or equal to m, and m is the number of features of the samples included by the second electronic device; Using the first and second matrices, n third matrices are generated, each corresponding to one of the n samples. The second matrix is an n×m matrix, and its j-th column includes n first random numbers corresponding to the j-th feature of each of the n samples. The third matrix is a k×m matrix, and its j-th column includes k second WOE values corresponding to k bins of the j-th feature. The second WOE value corresponding to the t-th bin of the j-th feature is obtained from the first WOE value corresponding to the t-th bin of the j-th feature and the first random number of the j-th feature of the i-th sample. i is an integer less than or equal to n, and t is a natural number less than k. The n third matrices are sent to the second electronic device. The n third matrices are used by the second electronic device to generate a fifth matrix. The fifth matrix is an n×m matrix. The j-th column of the fifth matrix includes n second WOE values that correspond one-to-one with the j-th feature of the n samples. The second WOE value corresponding to the j-th feature of the i-th sample is the second WOE value of the second electronic device based on the third matrix corresponding to the i-th sample and the second WOE value corresponding to the bin to which the i-th sample belongs on the j-th feature. Generate a fourth matrix, wherein the fourth matrix is an n×m matrix, and the j-th column of the fourth matrix includes n second random numbers that correspond one-to-one with the j-th feature of the n samples; the second random number corresponding to the j-th feature of the i-th sample is the first random number corresponding to the j-th feature of the i-th sample with the second symbol; the first symbol is the opposite of the second symbol.
2. The method according to claim 1, characterized in that, The second WOE value corresponding to the t-th bin of the j-th feature is the sum of the first WOE value corresponding to the t-th bin of the j-th feature and the first random number of the j-th feature of the i-th sample; The second random number corresponding to the j-th feature of the i-th sample is the negative of the first random number corresponding to the j-th feature of the i-th sample.
3. The method according to claim 1, characterized in that, The process of obtaining the first matrix includes: Generate a key pair, which includes a public key and a private key; The first column vector is encrypted using the public key to obtain the second column vector, wherein the first column vector includes n first labels corresponding one-to-one with the n samples, and the second column vector includes n second labels corresponding one-to-one with the n samples; Send the public key and the second column vector to the second electronic device; Receive target information sent by the second electronic device, the target information including the encrypted number of the k bins of the j-th feature, and the number of positive samples and the number of negative samples of the k bins of the j-th feature; Decrypt the target information using the private key; Using the number of positive and negative samples of the k bins of the decrypted j-th feature, determine the k first WOE values that correspond one-to-one with the k bins of the j-th feature.
4. A federated learning WOE coding method, applied to a second electronic device, characterized in that, include: The system receives n third matrices sent by a first electronic device, each corresponding to one of the n samples. Each third matrix is a k×m matrix, and the j-th column of the third matrix corresponding to the i-th sample includes k second WOE values corresponding to k bins of the j-th feature. The third matrices are generated by the first electronic device using a first matrix and a second matrix. The first matrix is a k×m matrix, and its j-th column includes k first WOE values corresponding to k bins of the j-th feature. The second matrix is an n×m matrix, and its j-th column includes n first random numbers corresponding to the j-th feature of the n samples. The second WOE values are obtained from the corresponding first WOE values and the first random numbers of the first symbols. The second WOE value of the bin corresponding to the j-th feature of the i-th sample is determined as the second WOE value corresponding to the j-th feature of the i-th sample, resulting in a fifth matrix. The fifth matrix is an n×m matrix, and the j-th column of the fifth matrix includes n second WOE values that correspond one-to-one with the j-th feature of the n samples. The bin corresponding to the j-th feature of the i-th sample is the bin in which the i-th sample is located after the second electronic device bins the n samples with the j-th feature, where i is a positive integer less than or equal to n. The first electronic device also generates a fourth matrix, which is an n×m matrix. The j-th column of the fourth matrix includes n second random numbers that correspond one-to-one with the j-th feature of the n samples. The second random numbers are the first random numbers with second symbols, and the first symbol is the opposite of the second symbol.
5. The method according to claim 4, characterized in that, Before receiving the n third matrices corresponding one-to-one with the n samples sent by the first electronic device, the method further includes: Receive the public key and the second column vector sent by the first electronic device, wherein the second column vector includes n second tags that correspond one-to-one with the n samples; Using the second labels corresponding to each sample in the t-th bin of the j-th feature, determine the number of positive and negative samples in the t-th bin of the j-th feature, and obtain the number of positive and negative samples in the k bins of the j-th feature, where t is a natural number less than k; The public key is used to encrypt the number of the k bins of the j-th feature, as well as the number of positive and negative samples of the k bins of the j-th feature; Send target information to the first electronic device. The target information includes the encrypted number of the k bins of the j-th feature, and the number of positive and negative samples of the k bins of the j-th feature.
6. The method according to claim 5, characterized in that, The step of determining the number of positive and negative samples in the t-th bin of the j-th feature using the second labels corresponding to each sample in the t-th bin includes: The sum of the second labels corresponding to each sample in the t-th bin of the j-th feature is determined as the number of negative samples in the t-th bin of the j-th feature; Subtract the number of negative samples in the t-th bin of the j-th feature from the target value to obtain the number of positive samples in the t-th bin of the j-th feature, where the target value is the number of samples included in the t-th bin of the j-th feature.
7. A WOE encoding device for federated learning, characterized in that, The device includes: The first acquisition module is used to acquire a first matrix, wherein the first matrix is a k×m matrix, and the j-th column of the first matrix includes k first WOE values corresponding one-to-one with the k bins of the j-th feature; the k bins of the j-th feature are the k bins obtained by the second electronic device by binning n samples with the j-th feature, where k and n are both integers greater than 1, j is a positive integer less than or equal to m, and m is the number of features of the samples included by the second electronic device; The first generation module is used to generate n third matrices corresponding one-to-one with the n samples using the first matrix and the second matrix. The second matrix is an n×m matrix, and its j-th column includes n first random numbers corresponding one-to-one with the j-th feature of the n samples. The third matrix is a k×m matrix, and its j-th column corresponding to the i-th sample includes k second WOE values corresponding one-to-one with the k bins of the j-th feature. The second WOE value corresponding to the t-th bin of the j-th feature is obtained from the first WOE value corresponding to the t-th bin of the j-th feature and the first random number of the j-th feature of the i-th sample. i is an integer less than or equal to n, and t is a natural number less than k. A first sending module is used to send the n third matrices to the second electronic device. The n third matrices are used by the second electronic device to generate a fifth matrix. The fifth matrix is an n×m matrix. The j-th column of the fifth matrix includes n second WOE values that correspond one-to-one with the j-th feature of the n samples. The second WOE value corresponding to the j-th feature of the i-th sample is the second WOE value of the second electronic device based on the third matrix corresponding to the i-th sample and the second WOE value corresponding to the bin to which the i-th sample belongs on the j-th feature. The second generation module is used to generate a fourth matrix, wherein the fourth matrix is an n×m matrix, and the j-th column of the fourth matrix includes n second random numbers that correspond one-to-one with the j-th feature of the n samples; the second random number corresponding to the j-th feature of the i-th sample is the first random number corresponding to the j-th feature of the i-th sample with the second symbol; the first symbol is the opposite of the second symbol.
8. A WOE encoding device for federated learning, characterized in that, The device includes: The second receiving module is used to receive n third matrices sent by the first electronic device, each corresponding to one of the n samples. The third matrices are k×m matrices, and the j-th column of the third matrix corresponding to the i-th sample includes k second WOE values corresponding to k bins of the j-th feature. The third matrices are generated by the first electronic device using a first matrix and a second matrix. The first matrix is a k×m matrix, and its j-th column includes k first WOE values corresponding to k bins of the j-th feature. The second matrix is an n×m matrix, and its j-th column includes n first random numbers corresponding to the j-th feature of the n samples. The second WOE values are obtained from the corresponding first WOE values and the first random numbers of the first symbols. The second determining module is used to determine the second WOE value of the bin corresponding to the j-th feature of the i-th sample as the second WOE value corresponding to the j-th feature of the i-th sample, thereby obtaining a fifth matrix. The fifth matrix is an n×m matrix, and the j-th column of the fifth matrix includes n second WOE values that correspond one-to-one with the j-th feature of the n samples. The bin corresponding to the j-th feature of the i-th sample is the bin where the i-th sample is located after the second electronic device bins the n samples according to the j-th feature, where i is a positive integer less than or equal to n. The first electronic device also generates a fourth matrix, which is an n×m matrix. The j-th column of the fourth matrix includes n second random numbers that correspond one-to-one with the j-th feature of the n samples. The second random numbers are the first random numbers with second symbols, where the first symbol is the opposite of the second symbol.
9. A WOE encoding device for federated learning, characterized in that, The device includes: a processor and a memory storing computer program instructions; the processor, when executing the computer program instructions, implements the WOE encoding method of federated learning as described in any one of claims 1 to 3; or, the WOE encoding method of federated learning as described in any one of claims 4 to 6.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement the WOE encoding method of federated learning as described in any one of claims 1 to 3. Alternatively, the WOE encoding method for federated learning as described in any one of claims 4 to 6.