Feature binning method, device, electronic device and storage medium
By adopting the feature binning method of homomorphic encryption and autonomous selection of binning methods in federated learning, the problem of unreasonable feature binning results in the prior art is solved, and the accuracy and flexibility of the model are improved.
Patent Information
- Application Number
- CN202111608427.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2041-12-24
AI Technical Summary
In federated learning, the existing technology lacks flexibility, resulting in unreasonable feature binning results, affecting the accuracy of the model.
By encrypting the sample tags with a homomorphic encryption key, a mapping relationship between the tag ciphertext and the sample ID is established, and communication is made between the first participant and the second participant, and the characteristics are boxed by selecting the binning method and quantity by themselves.
It improves the flexibility and rationality of feature binning, enhances the accuracy of the model, and meets the needs of multi-party joint modeling.
Smart Images

Figure CN114298211B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a feature binning method, device, electronic device and storage medium. Background Art
[0002] With the increasing demand for data security among the public, federated learning has received more and more attention. Federated learning combines cryptography with artificial intelligence, enabling each participating party in joint modeling to jointly model data from multiple participating parties without revealing their original data information under the protection of cryptographic technology.
[0003] During the joint modeling process, it is necessary to bin each feature of the data. The purpose of binning is to discretize the features so that the established model has higher robustness. When multiple parties jointly model, usually the same binning method can only be selected for different features. This method lacks flexibility and may lead to unreasonable binning results, resulting in low accuracy of the jointly established model. Therefore, there is an urgent need for a feature binning method to improve the flexibility of binning and ensure the reasonableness of binning results. Summary of the Invention
[0004] In view of the above, it is necessary to provide a feature binning method, aiming to improve the flexibility of binning and ensure the reasonableness of binning results.
[0005] The feature binning method provided by the present invention is applied to a first participating party, which is communicatively connected to a second participating party. The first participating party and the second participating party have the same sample objects and different sample features. The method includes:
[0006] Encrypting the label of each sample in the first sample set stored locally with a homomorphic encryption key to obtain the ciphertext of each sample's label, establishing a mapping relationship between the ciphertext of the label and the sample ID, and sending the mapping relationship to the second participating party;
[0007] Performing a binning operation on each first feature to be binned in the first sample set using a first binning method and a first binning quantity to obtain a first binning result corresponding to each first feature, and calculating the first quantity of each label in each first bin after binning each first feature based on the first binning result;
[0008] Receiving the sum of the ciphertexts of the labels of each sample in each second bin after binning each second feature sent by the second participating party, where the sum of the ciphertexts of the labels is calculated by the second participating party based on the mapping relationship and the second binning result, and the second binning result is obtained by the second participating party performing a binning operation on each second feature to be binned in the second sample set stored locally using a second binning method and a second binning quantity;
[0009] Based on the sum of the first quantity and the tag ciphertext, determine whether the first binning result and the second binning result are reasonable. When the determination is affirmative, respectively select the first target feature and the second target feature to be input into the model from the first feature and the second feature, perform encoding processing on the first target feature to obtain the binned data, and send the second target feature to the second party for the second party to encode it, thus completing the binning.
[0010] Optionally, the determining whether the first binning result and the second binning result are reasonable based on the sum of the first quantity and the tag ciphertext includes:
[0011] Based on the sum of the tag ciphertext, determine the second quantity of each tag in each second bin after binning the second feature.
[0012] Encode the features in each first bin based on the first quantity to obtain the first encoding value corresponding to each first bin, and determine whether the corresponding first binning result is reasonable based on the first encoding value.
[0013] Encode the features in each second bin based on the second quantity to obtain the second encoding value corresponding to each second bin, and determine whether the corresponding second binning result is reasonable based on the second encoding value.
[0014] Optionally, the tag includes a first tag and a second tag, and the determining the second quantity of each tag in each second bin after binning the second feature based on the sum of the tag ciphertext includes:
[0015] Receive the sum of the ciphertext differences corresponding to each second bin after binning the second feature sent by the second party, where the sum of the ciphertext differences is the sum of the differences between a preset value and the tag ciphertext of each sample in the corresponding second bin.
[0016] Based on the sum of the tag ciphertext, determine the second quantity of the first tag in each second bin.
[0017] Based on the sum of the ciphertext differences, determine the second quantity of the second tag in each second bin.
[0018] Optionally, the determining whether the corresponding first binning result is reasonable based on the first encoding value includes:
[0019] If the first encoding values of the first bins corresponding to a certain first feature are monotonic, then the first binning result corresponding to the first feature is reasonable.
[0020] Optionally, after determining whether the first binning result and the second binning result are reasonable, the method further includes:
[0021] If it is determined that a certain first binning result is unreasonable, adjust the first binning result and perform a reasonableness judgment on the adjusted result;
[0022] If it is determined that a certain second binning result is unreasonable, send a warning message to the second participating party to remind the second participating party to adjust the second binning result and perform a reasonableness judgment on the adjusted result.
[0023] Optionally, the steps of separately selecting the first target feature and the second target feature to be included in the model from the first feature and the second feature include:
[0024] Calculate the first information quantity value corresponding to each first feature based on the first coding value;
[0025] Calculate the second information quantity value corresponding to each second feature based on the second coding value;
[0026] Use the first feature corresponding to the first information quantity value within the preset numerical range as the first target feature, and use the second feature corresponding to the second information quantity value within the preset numerical range as the second target feature.
[0027] Optionally, the calculation formula of the first coding value is:
[0028]
[0029] where WOE a-i is the first coding value corresponding to the i-th first bin after binning of the a-th first feature, Q a-i is the first quantity of the second label in the i-th first bin after binning of the a-th first feature, P a-i is the first quantity of the first label in the i-th first bin after binning of the a-th first feature, Q T is the total quantity of the second label in the first sample set, P T is the total quantity of the first label in the first sample set.
[0030] To solve the above problems, the present invention also provides a feature binning device, the device includes:
[0031] An encryption module, configured to encrypt the label of each sample in the first sample set stored locally using a homomorphic encryption key to obtain the ciphertext of each sample's label, establish a mapping relationship between the ciphertext of the label and the sample ID, and send the mapping relationship to the second participating party;
[0032] A binning module, which is used to perform binning operations on each first feature to be binned in the first sample set by using a first binning method and a first binning quantity, obtain a first binning result corresponding to each first feature, and calculate a first quantity of each label in each first bin after binning of each first feature based on the first binning result;
[0033] A receiving module, which is used to receive the sum of the label ciphertexts of each sample in each second bin after binning of each second feature sent by a second participating party. The sum of the label ciphertexts is calculated by the second participating party based on the mapping relationship and the second binning result. The second binning result is obtained by the second participating party performing binning operations on each second feature to be binned in a second sample set stored locally by using a second binning method and a second binning quantity;
[0034] A judging module, which is used to judge whether the first binning result and the second binning result are reasonable based on the first quantity and the sum of the label ciphertexts. When the judgment is yes, a first target feature and a second target feature to be input into the model are respectively selected from the first feature and the second feature, encoding processing is performed on the first target feature to obtain binned data, and the second target feature is sent to the second participating party for the second participating party to perform encoding on it to complete binning.
[0035] To solve the above problems, the present invention further provides an electronic device, and the electronic device includes:
[0036] At least one processor; and,
[0037] A memory communicatively connected to the at least one processor; wherein,
[0038] The memory stores a feature binning program executable by the at least one processor. The feature binning program is executed by the at least one processor so that the at least one processor can execute the above feature binning method.
[0039] To solve the above problems, the present invention further provides a computer-readable storage medium, on which a feature binning program is stored. The feature binning program can be executed by one or more processors to implement the above feature binning method.
[0040] Compared with the prior art, the present invention first performs binning operations on each first feature in the first sample set using a first binning method and a first number of bins to obtain a first binning result corresponding to each first feature; then, receives the sum of the ciphertexts of the labels of the samples in each second bin after binning of each second feature sent by a second participant, where the sum of the ciphertexts of the labels is calculated based on a second binning result, and the second binning result is obtained by the second participant performing binning operations on each second feature in the second sample set using a second binning method and a second number of bins; finally, determines whether the first binning result and the second binning result are reasonable, and when the determination is yes, selects a first target feature and a second target feature, encodes the first target feature to obtain binned data, and sends the second target feature to the second participant for the second participant to encode it, thus completing binning. Each participant in the present invention can independently select one or more binning methods and corresponding numbers of bins for the features in their respective sample sets, increasing the flexibility of binning and improving the rationality of binning. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 is a flowchart of a feature binning method provided by an embodiment of the present invention;
[0042] Figure 2 is a module diagram of a feature binning device provided by an embodiment of the present invention;
[0043] Figure 3 is a structural diagram of an electronic device for implementing the feature binning method provided by an embodiment of the present invention;
[0044] The implementation, functional features, and advantages of the object of the present invention will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0045] In order to make the object, technical solution, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0046] It should be noted that in the present invention, the descriptions involving "first", "second", etc. are only for descriptive purposes, and cannot be construed as indicating or implying their relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one of such features. Additionally, the technical solutions between various embodiments may be combined with each other, but it must be based on the ability of those of ordinary skill in the art to implement. When the combination of technical solutions results in contradictions or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0047] The present invention provides a feature binning method, which is applied to a first participant, and the first participant is communicatively connected to a second participant. Referring to Figure 1 As shown, it is a schematic flowchart of the feature binning method provided by an embodiment of the present invention. This method can be executed by an electronic device (the electronic device corresponding to the first participant), and the electronic device can be implemented by software and / or hardware.
[0048] In this embodiment, the first participant and the second participant have the same sample objects and different sample features, and the feature binning method includes:
[0049] S1. Encrypt the label of each sample in the first sample set stored locally using a homomorphic encryption key to obtain the ciphertext of each sample's label, establish a mapping relationship between the ciphertext of the label and the sample ID, and send the mapping relationship to the second participant.
[0050] In this embodiment, the first participant and the second participant have the same sample objects and different sample features. The first sample set stored locally by the first participant carries labels, and the second sample set stored locally by the second participant does not contain labels.
[0051] For example, if the first participant is a bank and the second participant is a shopping platform, the first sample set corresponding to the bank includes sample data with sample IDs from 1 to 1000, and the sample data includes the number of deposit times, deposit amount, number of loan times, and loan amount of the user in the recent half year; the second sample set corresponding to the shopping platform includes sample data with sample IDs from 1 to 1000, and the sample data includes the number of shopping times, shopping amount, and shopping types of the user in the recent half year.
[0052] The sample ID can be a user ID, and the user ID can be the user's ID card number, mobile phone number, employee number, or other information that identifies the user's identity. The labels carried by the first sample set corresponding to the bank can include a first label and a second label. Among them, the first label is represented by 1, and the second label is represented by 0. The first label represents that the user has purchased the specified financial product, and the second label represents that the user has not purchased the specified financial product. Thus, in the first sample set, the samples with the label of 1 are positive samples, and the samples with the label of 0 are negative samples.
[0053] In this embodiment, a homomorphic encryption key is used to encrypt the labels. The characteristics of the homomorphic encryption algorithm are as follows: multiple homomorphically encrypted data are operated using a pre-designed calculation formula to obtain an operation result, and the operation result is decrypted. The decrypted result is the same as the result obtained by operating on the unencrypted original data using the same calculation formula. By using the homomorphic encryption algorithm, the normal operation of the data can be ensured without revealing the original data.
[0054] S2. Perform binning operations on each first feature to be binned in the first sample set using the first binning method and the first number of bins, obtain the first binning result corresponding to each first feature, and calculate the first quantity of each label in each first bin after binning each first feature based on the first binning result.
[0055] The features to be binned are usually continuous features or discrete features with a large number of values.
[0056] In this embodiment, multiple binning methods are provided. Each participating party can use the same binning method or different binning methods for different features in its sample set according to the actual situation (perform independent binning on each feature, and the binning process of other features is not interfered with). After determining the binning method, the corresponding number of bins can be determined by itself.
[0057] The binning methods include equal-frequency, equal-distance, optimal, and custom binning methods. Among them, the equal-frequency binning method means that the number of samples allocated in each bin is the same; the equal-distance binning method means that the segmented areas of each bin are the same; the optimal binning method means that recursive partitioning is used for binning, and the splitting points are determined according to statistical tests; the custom splitting method means that the user defines the splitting points by himself.
[0058] For example, the first binning method selected by the bank for the number of deposit times and the number of loan times in the first sample set is the equal-frequency binning method, and the corresponding first number of bins is 5 bins; the first binning method selected for the deposit amount and the loan amount is the equal-distance binning method, and the corresponding first number of bins is 10 bins.
[0059] After obtaining the first binning result corresponding to each first feature, the first quantity of each label in each first box is calculated respectively. For example, for the number of deposits, the first quantities of the first labels and the second labels in the five first boxes are (30, 20), (23, 27), (36, 14), (18, 32), and (28, 22), respectively.
[0060] S3. Receive the sum of the label ciphertexts of each sample in each second box after the second feature is binned, sent by the second participant, wherein the sum of the label ciphertexts is calculated by the second participant based on the mapping relationship and the second binning result, and the second binning result is obtained by the second participant performing a binning operation on each second feature to be binned in the second sample set stored locally using the second binning method and the second binning quantity.
[0061] The second participant selects a second binning method and a second bin quantity for each second feature to be binned in the second sample set stored locally. For example, the second binning method selected by the shopping platform for the number of purchases is an equidistant binning method, and the corresponding second bin quantity is 6; the second binning method selected for the shopping amount is a custom binning method, and the corresponding second bin quantity is 15.
[0062] The second sample set corresponding to the second participant does not contain label information, and it needs to use the label ciphertext of the first sample set to assist in counting the number of first labels and second labels in each box of each second feature. Because the label of the sample is private data, in order to ensure security, the first participant sends the mapping relationship between the label ciphertext and the sample ID to the second participant. Thus, the second participant can count the sum of the label ciphertexts of the samples in each box, and subsequently determine the number of first labels and second labels in each box based on the sum of the label ciphertexts.
[0063] The label ciphertext is encrypted with a homomorphic encryption key. Since a new random number is generated for encryption during each encryption process, the values obtained by encrypting the same label are not the same. For example, the label ciphertext obtained by encrypting the first label of the first sample in the first sample set is 5, and the label ciphertext obtained by encrypting the first label of the third sample may be 12. Therefore, it is impossible to directly count the number of label ciphertexts corresponding to the first label and the second label.
[0064] S4. Based on the sum of the first quantity and the label ciphertext, determine whether the first binning result and the second binning result are reasonable. When the judgment is yes, select the first target feature and the second target feature to be input into the mold from the first feature and the second feature respectively, perform encoding processing on the first target feature to obtain the binned data, and send the second target feature to the second participant for the second participant to encode it to complete the binning.
[0065] In this embodiment, the reasonableness of the binning result is determined by the index item WOE (weight of evidence), the target features to be included in the model are selected by the index item IV (information value), and then each participating party performs WOE encoding on the corresponding target features to obtain the binned data, completing the binning.
[0066] Determining whether the first binning result and the second binning result are reasonable based on the sum of the first quantity and the label ciphertext includes steps A11 - A13:
[0067] A11. Based on the sum of the label ciphertext, determine the second quantity of each label in each second bin after binning each second feature.
[0068] The step of determining the second quantity of each label in each second bin after binning each second feature based on the sum of the label ciphertext includes steps B11 - B13:
[0069] B11. Receive the sum of the ciphertext differences corresponding to each second bin after binning each second feature sent by the second participating party, where the sum of the ciphertext differences is the sum of the differences between a preset value and the label ciphertext of each sample in the corresponding second bin.
[0070] The second participating party not only sends the sum of the label ciphertext to the first participating party but also sends the sum of the ciphertext differences. In this embodiment, the preset value is 1, that is, the sum of the label ciphertext is The sum of the ciphertext differences is where S a-i is the sum of the label ciphertext corresponding to the i-th second bin after binning the a-th second feature, [y a-ij is the label ciphertext of the j-th sample in the i-th second bin after binning the a-th second feature, n is the total number of samples in the i-th second bin after binning the a-th second feature, and C a-i is the sum of the ciphertext differences corresponding to the i-th second bin after binning the a-th second feature.
[0071] B12. Based on the sum of the label ciphertext, determine the second quantity of the first label in each second bin.
[0072] Decrypting the sum of the label ciphertext using the homomorphic encryption key can obtain the second quantity of the first label. The reason is that decrypting the sum of the homomorphically encrypted data gives a value that is the same as the sum of the original data. Thus, the value obtained after decrypting the sum of the label ciphertext is the sum of the first labels, and since the first label is 1, the sum of the first labels is the second quantity of the first label.
[0073] B13. Based on the sum of the ciphertext differences, determine the second quantity of the second label in each second bin.
[0074] The sum of the ciphertext differences is The decrypted value is the same as the sum with (1 - y a-ij ), and the sum of (1 - y a-ij ) reflects the second quantity of the second label. Thus, by decrypting the sum of the ciphertext differences, the second quantity of the second label can be obtained.
[0075] A12. Encode the features in each first bin based on the first quantity to obtain a first encoded value corresponding to each first bin, and determine whether the corresponding first binning result is reasonable based on the first encoded value;
[0076] In this embodiment, WOE encoding is performed on the features in each first bin to obtain a first encoded value corresponding to each first bin.
[0077] The calculation formula for the first encoded value is:
[0078]
[0079] where WOE a-i is the first encoded value corresponding to the i-th first bin after binning the a-th first feature, Q a-i is the first quantity of the second label in the i-th first bin after binning the a-th first feature, P a-i is the first quantity of the first label in the i-th first bin after binning the a-th first feature, Q T is the total quantity of the second label in the first sample set, and P T is the total quantity of the first label in the first sample set.
[0080] Determining whether the corresponding first binning result is reasonable based on the first encoded value includes:
[0081] If the first encoded values of the first bins corresponding to a certain first feature are monotonic, then the first binning result corresponding to the first feature is reasonable.
[0082] Monotonicity means monotonic increase or monotonic decrease. For example, if the number of loan times is divided into 4 bins and the first encoded values are 0.2, 0.4, 0.45, 0.5, 0.53 respectively, showing an increasing trend, then the binning result corresponding to the number of loan times is reasonable.
[0083] A13. Encode the features in each second bin based on the second quantity to obtain a second encoded value corresponding to each second bin, and determine whether the corresponding second binning result is reasonable based on the second encoded value.
[0084] The calculation process of the second encoded value is the same as that of the first encoded value, and the judgment process of whether the second binning result is reasonable is the same as that of the first binning result.
[0085] After determining whether the first binning result and the second binning result are reasonable, the method further includes:
[0086] C11. If it is determined that a certain first binning result is unreasonable, adjust the first binning result and perform a reasonableness judgment on the adjusted result;
[0087] In this embodiment, if a certain first binning result is unreasonable, some first bins are merged using a custom binning method so that the WOE coding values corresponding to each adjusted first bin are monotonic.
[0088] C12. If it is determined that a certain second binning result is unreasonable, send a warning message to the second participant to remind the second participant to adjust the second binning result and perform a reasonableness judgment on the adjusted result.
[0089] The warning message includes the second coding values of each second bin corresponding to the second binning result.
[0090] The respectively selecting first target features and second target features to be included in the model from the first feature and the second feature includes:
[0091] D11. Calculate a first information quantity value corresponding to each first feature based on the first coding value;
[0092] The calculation formula for the first information quantity value is:
[0093]
[0094] where IV a is the first information quantity value corresponding to the a-th first feature, WOE a-i is the first coding value of the i-th first bin after binning the a-th first feature, Q a-i is the first quantity of the second label in the i-th first bin after binning the a-th first feature, P a-i is the first quantity of the first label in the i-th first bin after binning the a-th first feature, Q T is the total quantity of the second label in the first sample set, P T is the total quantity of the first label in the first sample set, and n is the number of first bins corresponding to the a-th first feature.
[0095] D12. Calculate a second information quantity value corresponding to each second feature based on the second coding value;
[0096] The calculation formula for the second information quantity value is the same as that for the first information quantity value.
[0097] D13. Take the first feature corresponding to the first information amount value within the preset numerical range as the first target feature, and take the second feature corresponding to the second information amount value within the preset numerical range as the second target feature.
[0098] The information amount value can measure the importance of the feature. In this embodiment, the preset numerical range can be 0.1 - 0.5. If the information amount value is not within this range, it indicates that the corresponding feature has little effect in modeling and can be deleted.
[0099] As can be seen from the above embodiments, for the feature binning method proposed by the present invention, first, perform binning operations on each first feature in the first sample set using the first binning method and the first binning quantity to obtain the first binning result corresponding to each first feature; then, receive the sum of the label ciphertexts of each sample in each second bin after binning of each second feature sent by the second participating party. The sum of the label ciphertexts is calculated based on the second binning result, and the second binning result is obtained by the second participating party performing binning operations on each second feature in the second sample set using the second binning method and the second binning quantity; finally, determine whether the first binning result and the second binning result are reasonable. When the determination is yes, select the first target feature and the second target feature, encode the first target feature to obtain the binned data, and send the second target feature to the second participating party for the second participating party to encode it, thus completing the binning. Each participating party in the present invention can independently select one or more binning methods and the corresponding binning quantities for the features in their respective sample sets, increasing the flexibility of binning and improving the rationality of binning.
[0100] As Figure 2 shown, it is a schematic diagram of the modules of a feature binning device provided by an embodiment of the present invention.
[0101] The feature binning device 100 of the present invention can be installed in an electronic device. According to the functions achieved, the feature binning device 100 can include an encryption module 110, a binning module 120, a receiving module 130, and a judgment module 140. The modules of the present invention can also be referred to as units, which refer to a series of computer program segments that can be executed by the processor of an electronic device and can complete fixed functions, and are stored in the memory of the electronic device.
[0102] In this embodiment, the functions of each module / unit are as follows:
[0103] The encryption module 110 is used to encrypt the label of each sample stored locally in the first sample set using a homomorphic encryption key to obtain the label ciphertext of each sample, establish a mapping relationship between the label ciphertext and the sample ID, and send the mapping relationship to the second participating party.
[0104] The binning module 120 is used to perform binning operations on each first feature to be binned in the first sample set by using the first binning method and the first binning quantity, obtain the first binning result corresponding to each first feature, and calculate the first quantity of each label in each first bin after binning each first feature based on the first binning result.
[0105] The receiving module 130 is used to receive the sum of the label ciphertexts of each sample in each second bin after binning the second features sent by the second party. The sum of the label ciphertexts is calculated by the second party based on the mapping relationship and the second binning result. The second binning result is obtained by the second party performing binning operations on each second feature to be binned in the second sample set stored locally by using the second binning method and the second binning quantity.
[0106] The judging module 140 is used to judge whether the first binning result and the second binning result are reasonable based on the first quantity and the sum of the label ciphertexts. When the judgment is yes, the first target feature and the second target feature to be input into the model are respectively selected from the first feature and the second feature, the first target feature is encoded to obtain the data after binning, and the second target feature is sent to the second party for the second party to encode it to complete the binning.
[0107] Judging whether the first binning result and the second binning result are reasonable based on the first quantity and the sum of the label ciphertexts includes steps A21 - A23:
[0108] A21. Based on the sum of the label ciphertexts, determine the second quantity of each label in each second bin after binning each second feature.
[0109] Determining the second quantity of each label in each second bin after binning each second feature based on the sum of the label ciphertexts includes steps B21 - B23:
[0110] B21. Receive the sum of the ciphertext differences corresponding to each second bin after binning the second features sent by the second party. The sum of the ciphertext differences is the sum of the differences between the preset value and the label ciphertexts of each sample in the corresponding second bin.
[0111] B22. Based on the sum of the label ciphertexts, determine the second quantity of the first label in each second bin.
[0112] B23. Based on the sum of the ciphertext differences, determine the second quantity of the second label in each second bin.
[0113] A22. Encode the features in each first bin based on the first quantity to obtain the first coding value corresponding to each first bin, and judge whether the corresponding first binning result is reasonable based on the first coding value.
[0114] The calculation formula for the first coding value is as follows:
[0115]
[0116] Where WOE a-i is the first coding value corresponding to the i-th first bin after the a-th first feature binning, Q a-i is the first quantity of the second label in the i-th first bin after the a-th first feature binning, P a-i is the first quantity of the first label in the i-th first bin after the a-th first feature binning, Q T is the total quantity of the second label in the first sample set, P T is the total quantity of the first label in the first sample set.
[0117] Judging whether the corresponding first binning result is reasonable based on the first coding value includes:
[0118] If the first coding values of the first bins corresponding to a certain first feature are monotonic, then the first binning result corresponding to the first feature is reasonable.
[0119] A23. Coding the features in each second bin based on the second quantity to obtain the second coding value corresponding to each second bin, and judging whether the corresponding second binning result is reasonable based on the second coding value.
[0120] After judging whether the first binning result and the second binning result are reasonable, the judging module 140 is further configured to:
[0121] C21. If it is judged that a certain first binning result is unreasonable, adjust the first binning result and perform a reasonableness judgment on the adjustment result;
[0122] C22. If it is judged that a certain second binning result is unreasonable, send a warning message to the second participant to remind the second participant to adjust the second binning result and perform a reasonableness judgment on the adjusted result.
[0123] Selecting the first target feature and the second target feature to be included in the model from the first feature and the second feature respectively includes:
[0124] D21. Calculating the first information quantity value corresponding to each first feature based on the first coding value;
[0125] D22. Calculating the second information quantity value corresponding to each second feature based on the second coding value;
[0126] D23. Take the first feature corresponding to the first information quantity value within the preset numerical range as the first target feature, and take the second feature corresponding to the second information quantity value within the preset numerical range as the second target feature.
[0127] As Figure 3 shown, it is a schematic structural diagram of an electronic device for implementing the feature binning method provided by an embodiment of the present invention.
[0128] The electronic device 1 is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. The electronic device 1 can be a computer, a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of hosts or network servers based on cloud computing, where cloud computing is a type of distributed computing and consists of a super virtual computer formed by a group of loosely coupled computer sets.
[0129] In this embodiment, the electronic device 1 includes, but is not limited to, a memory 11, a processor 12, and a network interface 13 that can communicate with each other through a system bus. The memory 11 stores a feature binning program 10, and the feature binning program 10 can be executed by the processor 12. Figure 3 Only the electronic device 1 with components 11 - 13 and the feature binning program 10 is shown. Those skilled in the art can understand that Figure 3 the shown structure does not constitute a limitation on the electronic device 1, and it may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0130] Among them, the memory 11 includes a memory and at least one type of readable storage medium. The memory provides a cache for the operation of the electronic device 1; the readable storage medium can be a non-volatile storage medium such as a flash memory, a hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the readable storage medium can be an internal storage unit of the electronic device 1, such as the hard disk of the electronic device 1; in other embodiments, the non-volatile storage medium can also be an external storage device of the electronic device 1, such as a plug-in hard disk equipped on the electronic device 1, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. In this embodiment, the readable storage medium of the memory 11 is generally used to store the operating system and various application software installed on the electronic device 1, such as storing the code of the feature binning program 10 in an embodiment of the present invention. In addition, the memory 11 can also be used to temporarily store various types of data that have been output or will be output.
[0131] In some embodiments, the processor 12 can be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 12 is generally used to control the overall operation of the electronic device 1, such as performing control and processing related to data interaction or communication with other devices. In this embodiment, the processor 12 is used to run the program code stored in the memory 11 or process data, such as running the feature binning program 10, etc.
[0132] The network interface 13 can include a wireless network interface or a wired network interface, and this network interface 13 is used to establish a communication connection between the electronic device 1 and a client (not shown in the figure).
[0133] Optionally, the electronic device 1 can further include a user interface, and the user interface can include a display, an input unit such as a keyboard. Optionally, the user interface can further include a standard wired interface and a wireless interface. Optionally, in some embodiments, the display can be an LED display, a liquid crystal display, a touch liquid crystal display, and an OLED (Organic Light-Emitting Diode) toucher, etc. Among them, the display can also be appropriately referred to as a display screen or a display unit, and is used to display the information processed in the electronic device 1 and to display a visual user interface.
[0134] It should be understood that the above embodiments are for illustrative purposes only and the scope of the patent application is not limited by this structure.
[0135] The feature binning program 10 stored in the memory 11 of the electronic device 1 is a combination of multiple instructions, and when running in the processor 12, it can implement the steps in the above feature binning method.
[0136] Specifically, for the specific implementation method of the above feature binning program 10 by the processor 12, reference can be made to Figure 1 the description of the relevant steps in the corresponding embodiments, which will not be elaborated here.
[0137] Furthermore, if the modules / units integrated in the electronic device 1 are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. The computer-readable medium can be non-volatile or volatile. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM, Read-Only Memory).
[0138] The feature binning program 10 is stored on the computer-readable storage medium, and the feature binning program 10 can be executed by one or more processors to implement the steps in the above feature binning method.
[0139] In several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division, and there can be other division methods in actual implementation.
[0140] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0141] In addition, in each embodiment of the present invention, the functional modules can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0142] Therefore, in any aspect, the embodiments should be regarded as exemplary and non-limiting. The scope of the present invention is defined by the appended claims rather than the above description. Thus, all changes falling within the meaning and scope of the equivalent elements of the claims are intended to be embraced within the present invention. Any reference signs in the claims should not be construed as limiting the claims concerned.
[0143] The blockchain referred to in the present invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. Blockchain, in essence, is a decentralized database, a series of data blocks generated by using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. The blockchain can include the blockchain underlying platform, the platform product service layer, and the application service layer, etc.
[0144] In addition, it is obvious that the word "including" does not exclude other units or steps, and the singular does not exclude the plural. The multiple units or devices stated in the system claims can also be implemented by one unit or device through software or hardware. Words such as "second" are used to denote names and do not denote any particular order.
[0145] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A feature binning method is applied to a first party, and the first party is communicatively connected to a second party. It is characterized in that the first party and the second party have the same sample objects but different sample features, and the method includes: encrypting the label of each sample in the first sample set stored locally using a homomorphic encryption key to obtain the ciphertext of each sample's label, establishing a mapping relationship between the ciphertext of the label and the sample ID, and sending the mapping relationship to the second party, where the first sample set is the first business data sample with labels stored by the first party; performing a binning operation on each first feature to be binned in the first sample set using a first binning method and a first binning quantity to obtain a first binning result corresponding to each first feature, and calculating the first quantity of each label in each first bin after binning each first feature based on the first binning result; receiving the sum of the ciphertexts of the labels of each sample in each second bin after binning each second feature sent by the second party, where the sum of the ciphertexts of the labels is calculated by the second party based on the mapping relationship and the second binning result, and the second binning result is obtained by the second party performing a binning operation on each second feature to be binned in the second sample set stored locally using a second binning method and a second binning quantity, where the second sample set is the second business data sample without labels stored by the second party; judging whether the first binning result and the second binning result are reasonable based on the first quantity and the sum of the ciphertexts of the labels. When the judgment is yes, select a first target feature and a second target feature to be included in the model from the first feature and the second feature respectively, perform encoding processing on the first target feature to obtain binned data, and send the second target feature to the second party for it to perform encoding to complete binning.
2. The feature binning method according to claim 1, It is characterized in that the judging whether the first binning result and the second binning result are reasonable based on the first quantity and the sum of the ciphertexts of the labels includes: determining the second quantity of each label in each second bin after binning each second feature based on the sum of the ciphertexts of the labels; encoding the features in each first bin based on the first quantity to obtain a first encoding value corresponding to each first bin, and judging whether the corresponding first binning result is reasonable based on the first encoding value; encoding the features in each second bin based on the second quantity to obtain a second encoding value corresponding to each second bin, and judging whether the corresponding second binning result is reasonable based on the second encoding value.
3. The feature binning method according to claim 2, It is characterized in that the label includes a first label and a second label, and the determining the second quantity of each label in each second bin after binning each second feature based on the sum of the ciphertexts of the labels includes: receiving the sum of the ciphertext differences corresponding to each second bin after binning each second feature sent by the second party, where the sum of the ciphertext differences is the sum of the differences between a preset value and the ciphertext of the label of each sample in the corresponding second bin; Determine the second quantity of the first tags in each second bin based on the sum of the tag ciphertexts; Determine the second quantity of the second tags in each second bin based on the sum of the ciphertext differences.
4. The feature binning method according to claim 2, wherein, the determining whether the corresponding first binning result is reasonable based on the first encoding value includes: if the first encoding values of the respective first bins corresponding to a certain first feature are monotonic, then the first binning result corresponding to the first feature is reasonable.
5. The feature binning method according to claim 1, wherein, after determining whether the first binning result and the second binning result are reasonable, the method further includes: if it is determined that a certain first binning result is unreasonable, adjust the first binning result and perform a reasonableness judgment on the adjusted result; if it is determined that a certain second binning result is unreasonable, send a warning message to the second participating party to remind the second participating party to adjust the second binning result and perform a reasonableness judgment on the adjusted result.
6. The feature binning method according to claim 1, wherein, the selecting the first target feature and the second target feature to be input into the model from the first feature and the second feature respectively includes: calculating the first information quantity value corresponding to each first feature based on the first encoding value; calculating the second information quantity value corresponding to each second feature based on the second encoding value; taking the first feature corresponding to the first information quantity value within a preset numerical range as the first target feature, and taking the second feature corresponding to the second information quantity value within the preset numerical range as the second target feature.
7. The feature binning method according to claim 2, wherein, the calculation formula of the first encoding value is: Among them, WOE a-i is the first coding value corresponding to the i-th first bin after the a-th first feature binning, Q a-i is the first quantity of the second label in the i-th first bin after the a-th first feature binning, P a-i is the first quantity of the first label in the i-th first bin after the a-th first feature binning, Q T is the total quantity of the second label in the first sample set, P T is the total quantity of the first label in the first sample set.
8. A feature binning device, wherein, the device includes: an encryption module, configured to encrypt the tags of each sample in the first sample set stored locally using a homomorphic encryption key to obtain the tag ciphertexts of each sample, establish a mapping relationship between the tag ciphertexts and the sample IDs, and send the mapping relationship to the second participating party, wherein the first sample set is the first business data samples carrying tags stored by the first participating party; a binning module, configured to perform a binning operation on each first feature to be binned in the first sample set using a first binning method and a first binning quantity to obtain a first binning result corresponding to each first feature, and calculate the first quantity of each tag in each first bin after binning of each first feature based on the first binning result; a receiving module, configured to receive the sum of the tag ciphertexts of each sample in each second bin after binning of each second feature sent by the second participating party, the sum of the tag ciphertexts being calculated by the second participating party based on the mapping relationship and the second binning result, and the second binning result being obtained by the second participating party performing a binning operation on each second feature to be binned in the second sample set stored locally using a second binning method and a second binning quantity, wherein the second sample set is the second business data samples without tags stored by the second participating party; A judgment module, configured to judge whether the first binning result and the second binning result are reasonable based on the sum of the first quantity and the tag ciphertext. When the judgment is affirmative, the first target feature and the second target feature to be input into the model are respectively selected from the first feature and the second feature. The encoding process is performed on the first target feature to obtain the binned data, and the second target feature is sent to the second participating party for the second participating party to perform encoding on it to complete the binning.
9. An electronic device, characterized in that the electronic device includes: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, the memory stores a feature binning program executable by the at least one processor, and the feature binning program is executed by the at least one processor so that the at least one processor can execute the feature binning method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a feature binning program, and the feature binning program can be executed by one or more processors to implement the feature binning method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Feature box separation method and device and readable storage medium
CN111523679A
Feature selection method and device, readable storage medium and computer program product
CN112836733A