Two-party transverse federation security aggregation method and system based on K-means clustering

Through the two-party horizontal federal security aggregation method based on K-mean clustering, the central point and data volume are transmitted between the two nodes using encryption and blinding technology, the problems of data privacy leakage and low efficiency in horizontal federal learning are solved, and high efficiency is achieved , secure data aggregation.

CN119106441AActive Publication Date: 2024-12-10LINGSHU TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411261600.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2024-12-10
Estimated Expiration
2044-09-10

AI Technical Summary

Technical Problem

In the horizontal federated learning scenario, the traditional k-means clustering algorithm cannot be directly applied to data sets where both parties have the same feature space but different sample spaces, because directly exchanging data will leak data privacy, and the use of third-party nodes in the existing technology leads to efficiency Low and poses safety risks, lacking effective solutions.

Method used

Using the two-party horizontal federal security aggregation method based on K-mean clustering, data transmission is carried out through two nodes, and third-party nodes are avoided, and only the central point and data volume are transmitted are small. Encryption and blinding technology are used to ensure data security and realize data aggregation. .

Benefits of technology

It improves data security and processing efficiency, avoids data leakage and intermediate data leakage, reduces data transmission volume, and enhances security and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119106441A_ABST
    Figure CN119106441A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a two-party transverse federation security aggregation method and system based on K-means clustering, and the method comprises the steps: S1, enabling each participant to randomly generate a preset number of initial center points according to a local sample; s2, each participant performs clustering according to the distance between the local sample and the current center point to obtain a local clustering result; s3, each participant updates the current center point according to a local clustering result to obtain an updated center point; s4, calculating the sum of the distances between the central point and the updated central point by each participant; s5, judging whether the current iteration is converged or reaches the maximum iteration number according to the distance sum, and if the current iteration is converged or reaches the maximum iteration number, calculating an aggregation model by adopting a local update center point by each participant; and otherwise, repeating the steps S2-S5 until the model converges or reaches the maximum number of iterations to obtain an aggregation model. And the transmission efficiency is improved on the basis of ensuring the data transmission security.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of privacy computing, and in particular to a bilateral horizontal federation security aggregation method based on K-means clustering. Background Art

[0002] In the horizontal federated learning scenario, that is, when both parties P0 and P1 have data sets with the same feature space but different sample spaces, the traditional k-means clustering algorithm cannot be directly applied because direct data exchange will leak their respective data privacy.

[0003] The existing horizontal federated clustering learning method has a third-party node. Although it can protect data privacy to a certain extent, there is still room for improvement in efficiency and security.

[0004] There is currently no effective solution to the problems of low efficiency and potential safety hazards caused by using third-party nodes in the existing technology. Summary of the invention

[0005] To solve the above problems, the present invention provides a bilateral horizontal federation security aggregation method and system based on K-means clustering, which only uses two-party nodes for data transmission, avoiding the poor security problem of using third-party nodes, and uses a central point for transmission during the transmission process, with a small amount of transmitted data, to solve the problem of low transmission efficiency.

[0006] To achieve the above purpose, the embodiment of the present invention provides a two-party horizontal federation security aggregation method based on K-means clustering, including: S1, each participant randomly generates a preset number of initial center points according to local samples; wherein the participants include the first participant and the second participant; S2, each participant clusters according to the distance between the local sample and the current center point to obtain a local clustering result; wherein the current center point in the initial state is the initial center point; S3, each participant updates the current center point according to the local clustering result to obtain an updated center point; S4, each participant calculates the distance sum according to the local current center point and the updated center point; S5, according to the distance sum, judges whether the current iteration converges or reaches the maximum number of iterations, if converges or reaches the maximum number of iterations, each participant uses the local updated center point to calculate the aggregation model; otherwise, repeats steps S2-S5 until the aggregation model is obtained. .

[0007] Further optionally, each participant uses a local update center point to calculate an aggregation model, including: S501, the first participant generates a public key and a private key, and uses the public key to encrypt the local first local model and the first sample amount respectively to obtain a first encrypted local model and a first encrypted sample amount, and sends the public key, the first encrypted local model and the first encrypted sample amount to the second participant; wherein the first local model is obtained according to the update center point of the first participant; S502, the second participant uses the public key to encrypt the local second local model and the second sample amount respectively to obtain a second encrypted local model and a second encrypted sample amount, securely aggregates the first encrypted local model with the second encrypted local model to obtain an encrypted aggregation model, and securely aggregates the first encrypted sample amount with the second encrypted sample amount to obtain an encrypted aggregation Aggregate sample size; wherein, the second local model is obtained according to the update center point of the second participant; S503, the second participant uses random numbers to blind the encrypted aggregation model and the encrypted aggregation sample size respectively, to obtain a blinded encrypted aggregation model and a blinded encrypted aggregation sample size, and sends the blinded encrypted aggregation model and the blinded encrypted aggregation sample size to the first participant; S504, the first participant uses the private key to decrypt the blinded encrypted aggregation model and the blinded encrypted aggregation sample size respectively, to obtain a blinded aggregation model and a blinded aggregation sample size, and sends the blinded aggregation model and the blinded aggregation sample size to the second participant; S505, the second participant deblinds the blinded aggregation model and the blinded aggregation sample size according to random numbers, to obtain an aggregation model, and sends the aggregation model to the first participant.

[0008] Further optionally, each participant clusters the local sample according to the distance between the local sample and the current center point to obtain a local clustering result, including: S201, calculating the Euclidean distance of each local sample relative to all current center points; S202, classifying each local sample into the category corresponding to the current center point with the smallest Euclidean distance to obtain a clustering result.

[0009] Further optionally, each participant updates the current center point according to the local clustering result to obtain an updated center point, including: S301, forming a clustering data set with local samples of each category in the clustering result; S302, calculating the arithmetic mean of each feature in each clustering data set, and taking the arithmetic mean of all features as the updated center point of the category to which they belong.

[0010] Further optionally, each participant calculates the distance sum based on the local current center point and the updated center point, including: S401, the second participant calculates the first center point distance between the local current center point and the updated center point; S402, the first participant calculates the second center point distance between the local current center point and the updated center point, and sends the second center point distance to the second participant; S403, the second participant calculates the distance sum of the first center point distance and the second center point distance.

[0011] On the other hand, the present invention also provides a bilateral horizontal federation security aggregation system based on K-means clustering, including: an initial center point generation module, used for each participant to randomly generate a preset number of initial center points based on local samples; wherein, each participant includes a first participant and a second participant; a clustering module, used for each participant to cluster according to the distance between the local sample and the current center point to obtain a local clustering result; wherein, in the initial state, the current center point is the initial center point; a center point update module, used for each participant to update the current center point according to the local clustering result to obtain an updated center point; a distance and calculation module, used for each participant to calculate the distance and the updated center point based on the local current center point and the updated center point; an iteration module, used to determine whether the current iteration converges or reaches the maximum number of iterations based on the distance and, if converged or reaches the maximum number of iterations, each participant adopts the local updated center point to calculate the aggregation model; otherwise, repeat the steps of the clustering module, the center point update module, the distance and calculation module and the iteration module until the aggregation model is obtained.

[0012] Further optionally, the model aggregation module includes: an encryption submodule, which is used by the first participant to generate a public key and a private key, and use the public key to encrypt the local first local model and the first sample amount respectively to obtain the first encrypted local model and the first encrypted sample amount, and send the public key, the first encrypted local model and the first encrypted sample amount to the second participant; wherein the first local model is obtained according to the update center point of the first participant; an aggregation submodule, which is used by the second participant to use the public key to encrypt the local second local model and the second sample amount respectively to obtain the second encrypted local model and the second encrypted sample amount, securely aggregate the first encrypted local model with the second encrypted local model to obtain an encrypted aggregation model, and securely aggregate the first encrypted sample amount with the second encrypted sample amount to obtain an encrypted aggregation sample amount; wherein, The second local model is obtained according to the update center point of the second participant; a blinding submodule is used for the second participant to use random numbers to blind the encrypted aggregation model and the encrypted aggregation sample size respectively, to obtain the blinded encrypted aggregation model and the blinded encrypted aggregation sample size, and send the blinded encrypted aggregation model and the blinded encrypted aggregation sample size to the first participant; a decryption submodule is used for the first participant to use the private key to decrypt the blinded encrypted aggregation model and the blinded encrypted aggregation sample size respectively, to obtain the blinded aggregation model and the blinded aggregation sample size, and send the blinded aggregation model and the blinded aggregation sample size to the second participant; a deblinding submodule is used for the second participant to deblind the blinded aggregation model and the blinded aggregation sample size respectively according to random numbers, to obtain the aggregation model, and send the aggregation model to the first participant.

[0013] Further optionally, the clustering module includes: a distance calculation submodule, used to calculate the Euclidean distance of each local sample relative to all current center points; and a clustering submodule, used to classify each local sample into the category corresponding to the current center point with the smallest Euclidean distance to obtain a clustering result.

[0014] Further optionally, the center point update module includes: a cluster data set generation submodule, used to form a cluster data set from local samples of each category in the clustering results; a center point update submodule, used to calculate the arithmetic mean of each feature in each cluster data set, and use the arithmetic mean of all features as the updated center point of the category to which they belong.

[0015] Further optionally, the distance and calculation module includes: a first calculation submodule, used by the second participant to calculate the first center point distance between the local current center point and the updated center point; a second calculation submodule, used by the first participant to calculate the second center point distance between the local current center point and the updated center point, and send the second center point distance to the second participant; and a summation submodule, used by the second participant to calculate the sum of the first center point distance and the second center point distance.

[0016] The above technical solution has the following beneficial effects: by transmitting and analyzing data between two parties, data leakage is ensured and data security is improved; in the process of data security aggregation, encryption and blinding technology are used to ensure that the two parties will not leak the original data to each other during the data transmission process, and will not rely on any third party, nor will the intermediate data be leaked to a third party, further improving security; in the process of security aggregation, only the central point and data volume are encrypted and transmitted, reducing the amount of data transmission, thereby improving data processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 It is a flow chart of a bilateral horizontal federation security aggregation method based on K-means clustering provided in an embodiment of the present invention;

[0019] Figure 2 is a flow chart of a model security aggregation method provided by an embodiment of the present invention;

[0020] Figure 3 is a flow chart of a clustering method provided by an embodiment of the present invention;

[0021] Figure 4 is a flow chart of a center point updating method provided by an embodiment of the present invention;

[0022] Figure 5 is a flow chart of a distance and calculation method provided by an embodiment of the present invention;

[0023] Figure 6 It is a structural diagram of a bilateral horizontal federation security aggregation system based on K-means clustering provided in an embodiment of the present invention;

[0024] Figure 7 is a schematic diagram of the structure of an iteration module provided by an embodiment of the present invention;

[0025] Figure 8 is a schematic diagram of the structure of a clustering module provided by an embodiment of the present invention;

[0026] Fig. 9 is a structural diagram of a central point update module provided in an embodiment of the present invention;

[0027] Fig.10It is a schematic diagram of the structure of the distance and calculation module provided in an embodiment of the present invention.

[0028] Figure markings: 100-initial center point generation module; 200-clustering module; 2001-distance calculation submodule; 2002-clustering submodule; 300-center point update module; 3001-clustering data set generation submodule; 3002-center point update submodule; 400-distance and calculation module; 4001-first calculation submodule; 4002-second calculation submodule; 4003-summation submodule; 500-iteration module; 5001-encryption submodule; 5002-aggregation submodule; 5003-blinding submodule; 5004-decryption submodule; 5005-de-blinding submodule. DETAILED DESCRIPTION

[0029] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0030] In order to solve the problems of low security and efficiency of horizontal federation in the prior art, the embodiment of the present invention provides a two-party horizontal federation security aggregation method based on K-means clustering. Figure 1 is a flow chart of a bilateral horizontal federation security aggregation method based on K-means clustering provided in an embodiment of the present invention, such as Figure 1 As shown, the method includes:

[0031] S1. Each participant randomly generates a preset number of initial center points based on a local sample; wherein each participant includes a first participant and a second participant;

[0032] Horizontal federation is often used in scenarios such as loan amount prediction, investment risk analysis, medical data analysis, and market analysis. Both parties involved in horizontal federated learning do not want to share raw data with each other, but need to perform data analysis through aggregated models.

[0033] Taking the market analysis scenario as an example, the two participants are the first retailer P0 and the second retailer P1. The two parties hope to cooperate in market segmentation analysis to better position their marketing strategies. The first retailer P0 has extensive customer purchase data, while the second retailer P1 has detailed customer feedback and survey data. Due to privacy policy and business confidentiality considerations, they do not want to share the original data directly. Therefore, model aggregation is performed to use the obtained aggregated model to identify different customer groups, and to design customized marketing strategies for these groups, such as personalized recommendations, specific discounts, etc., to improve customer satisfaction and sales performance.

[0034] Taking the medical data analysis scenario as an example, the two participants are the first hospital P0 and the second hospital P1. The two parties hope to jointly analyze the health data of patients to study the pathogenesis and treatment effects of specific diseases. Hospital P0 has a large number of electronic health records of patients, while hospital P1 has detailed treatment response data. Due to legal requirements for patient privacy protection, they cannot directly share sensitive patient data. Model aggregation is performed to use the aggregated model to identify specific health characteristics and treatment responses of different patient groups, thereby providing more accurate guidance for clinical treatment, optimizing treatment plans, and improving treatment effects. At the same time, this form of cooperation also helps to accelerate the development of new drugs and treatments.

[0035] In order to achieve model aggregation between the two parties, the data of each participant must first be standardized so that the feature dimensions of both parties are the same. For example, in a medical data analysis scenario, one participant P0 obtains a data set X after data standardization, including m samples, each sample has f features, that is, m patients, each patient has f features (age, gender, disease type, treatment duration, etc.). The other participant P1 obtains a data set Y after data standardization, including n samples, each sample has f features.

[0036] The first participant P1 after standardization has a standardized data set Y with n rows and f columns, and the second participant P0 after standardization has a standardized data set X with m rows and f columns. Assuming there are k categories, k>=2, and the preset number is the number of categories k, then the first participant and the second participant each randomly generate k initial center points.

[0037] The P0 sample ID list is ids_0, the P0 center point: the i-th center point Ci = [Xr0, Xr1, Xr2, ... Xr (f-1)], where i = 0, 1, 2, ..., k-1; r = random.sample (ids_0, k);

[0038] The P1 sample ID list is ids_1, P1 center point: the jth center point Cj = [Yr0, Yr1, Yr2, …Yr(f-1)], where j = 0, 1, 2, …, k-1; r = random.sample(ids_1, k).

[0039] S2. Each participant clusters according to the distance between the local sample and the current center point to obtain a local clustering result; wherein, in the initial state, the current center point is the initial center point;

[0040] Before the iteration starts, the initial center point is used as the current center point for the first clustering. The first participant P1 calculates the Euclidean distance between each sample in its standardized data set and the k current center points, and clusters each sample according to the Euclidean distance, that is, classifies each sample into the category of the current center point closest to it, so as to obtain the local clustering result of the first participant P1.

[0041] The second participant P0 obtains the local clustering result of the second participant in the same manner.

[0042] S3. Each participant updates the current center point according to the local clustering result to obtain an updated center point;

[0043] The first participant P1 updates the current center point according to the characteristics of the samples in the local clustering result to obtain an updated center point for each category.

[0044] The second participant P0 obtains the updated center point of the first participant in the same way.

[0045] S4. Each participant calculates the distance sum based on the local current center point and the updated center point;

[0046] Afterwards, the two participants calculate the center point distance based on the local current center point and the updated center point respectively, and calculate the distance sum based on the center point distance of the two parties as a judgment mark for whether the subsequent iterations converge.

[0047] S5. Determine whether the current iteration converges or reaches the maximum number of iterations based on the distance and, if so, each participant uses the local update center point to calculate the aggregation model; otherwise, repeat steps S2-S5 until the aggregation model is obtained.

[0048] If the sum of the distances is greater than the preset convergence distance, the iteration is considered not to have converged, otherwise the iteration is considered to have converged. In addition, the number of iterations can also be used for judgment. If the current number of iterations reaches the maximum number of iterations, the iteration is considered to have converged, otherwise, it is considered not to have converged.

[0049] If the iteration converges, the two parties use their respective update centers to aggregate the security model of the horizontal federation according to the Paillier encryption protocol to obtain an aggregated model to ensure that data privacy is not leaked.

[0050] If the iteration does not converge, repeat the above steps S2-S5, and increase the number of iterations by 1 each time until the iteration converges or reaches the maximum number of iterations, and use the updated center point obtained in the last iteration for safe aggregation to obtain an aggregated model.

[0051] It should be noted that in each iteration, the updated center point needs to be used as the current center point for subsequent calculations.

[0052] As an optional implementation, Figure 2 is a flow chart of a model security aggregation method provided by an embodiment of the present invention, such as Figure 2 As shown, each participant uses a local update center to calculate the aggregation model, including:

[0053] S501, the first participant generates a public key and a private key, and uses the public key to encrypt the local first local model and the first sample volume respectively, to obtain the first encrypted local model and the first encrypted sample volume, and sends the public key, the first encrypted local model and the first encrypted sample volume to the second participant; wherein the first local model is obtained according to the update center point of the first participant;

[0054] The first participant P1 uses the Paillier encryption protocol to generate a key pair, namely a public key and a private key, and uses the public key to encrypt the local first local model and the first sample amount respectively to obtain the first encrypted local model and the first encrypted sample amount, and sends the public key, the first encrypted local model and the first encrypted sample amount to the second participant P0.

[0055] S502, the second participant uses the public key to encrypt the local second local model and the second sample volume respectively, obtain the second encrypted local model and the second encrypted sample volume, securely aggregate the first encrypted local model with the second encrypted local model to obtain an encrypted aggregate model, and securely aggregate the first encrypted sample volume with the second encrypted sample volume to obtain an encrypted aggregate sample volume; wherein the second local model is obtained according to the update center point of the second participant;

[0056] After receiving the public key, the first encrypted local model and the first encrypted sample amount, the second participant P0 uses the public key to encrypt the second local model and the second sample amount to obtain the second encrypted local model and the second encrypted sample amount.

[0057] The two encrypted local models are securely aggregated to obtain an encrypted aggregate model, and the two encrypted sample sizes are aggregated to obtain an encrypted aggregate sample size.

[0058] S503: The second participant uses random numbers to blind the encryption aggregation model and the encryption aggregation sample size, respectively, to obtain a blind encryption aggregation model and a blind encryption aggregation sample size, and sends the blind encryption aggregation model and the blind encryption aggregation sample size to the first participant;

[0059] The second participant P0 randomly generates two random numbers r0 and r1 in advance, and uses the two random numbers to blind the encryption aggregation model and the encryption aggregation sample size, respectively, to obtain the blind encryption aggregation model and the blind encryption aggregation sample size. The blind encryption aggregation model and the blind encryption aggregation sample size are sent to the first participant P1.

[0060] S504: The first participant uses the private key to decrypt the blinded encrypted aggregation model and the blinded encrypted aggregation sample size respectively to obtain the blinded aggregation model and the blinded aggregation sample size, and sends the blinded aggregation model and the blinded aggregation sample size to the second participant;

[0061] After receiving the blinded encrypted aggregation model and the blinded encrypted aggregation sample size, the first participant P1 decrypts them respectively using the private key to obtain the blinded aggregation model and the blinded aggregation sample size. Afterwards, the blinded aggregation model and the blinded aggregation sample size are sent to the second participant P0.

[0062] S505. The second participant deblinds the blinded aggregation model and the blinded aggregation sample size according to the random number to obtain the aggregation model, and sends the aggregation model to the first participant.

[0063] The second participant P0 de-blinds the aggregation model according to two random numbers to obtain the aggregation model.

[0064] As an optional implementation, the aggregation model = blinded aggregation model / blind aggregation sample size*r1 / r0, and the aggregation model is sent to the first participant P1.

[0065] As an optional implementation, Figure 3 is a flow chart of a clustering method provided by an embodiment of the present invention, such as Figure 3 As shown in the figure, each participant clusters according to the distance between the local sample and the current center point, and obtains the local clustering results, including:

[0066] S201, calculating the Euclidean distance of each local sample relative to all current center points;

[0067] Taking a local sample Xt of the second participant P0 as an example, Xt is a vector with f dimensions, t = [0, 1, 2, …, m-1], calculate the Euclidean distance between the sample Xt and a central point Ci dti = sqrt((Xt0-Xr0)^2+(Xt1-Xr1)^2+…+(Xt(f-1)-Xr(f-1))^2).

[0068] Calculate the Euclidean distance between each local sample in the second participant P0 and all current center points in the above way, and generate the distance dataset D mk :

[0069]

[0070] In the same way, the Euclidean distance between each local sample in the first participant P1 and the current center point is calculated, and the distance dataset D is generated. nk :

[0071]

[0072] S202: Classify each local sample into the category corresponding to the current center point with the smallest Euclidean distance to obtain a clustering result.

[0073] Taking the second participant P0 as an example, the distance dataset D of the second participant P0 is mk In , the column index value corresponding to the minimum value of each row is used as the category to which the sample belongs, so as to obtain the clustering result cluster0 of the second participant P0 including k categories. The clustering result cluster1 of the first participant P1 including k categories is obtained in the same way.

[0074] As an optional implementation, Figure 4 is a flow chart of a center point updating method provided by an embodiment of the present invention. Figure 4 As shown, each participant updates the current center point according to the local clustering result to obtain an updated center point, including:

[0075] S301, forming a clustering data set from local samples of each category in the clustering result;

[0076] S302: Calculate the arithmetic mean of each feature in each cluster data set, and use the arithmetic mean of all features as the update center point of the corresponding category.

[0077] The local samples of the same category in the clustering results are grouped into cluster data sets, and the arithmetic mean of each column feature in each cluster data set is calculated. The array of k rows and f columns formed by combining all the arithmetic mean values ​​is used as the set of updated center points, and each row represents the updated center point of a category.

[0078] As an optional implementation, Figure 5 is a flow chart of the distance and calculation method provided by an embodiment of the present invention, such as Figure 5 As shown, each participant calculates the distance sum based on the local current center point and the updated center point, including:

[0079] S401, the second participant calculates the first center point distance between the local current center point and the updated center point;

[0080] The second participant P0 calculates the Euclidean distance between the local current center point and the updated center point as the first center point distance d0.

[0081] S402, the first participant calculates the second center point distance between the local current center point and the updated center point, and sends the second center point distance to the second participant;

[0082] The first participant P1 calculates the Euclidean distance between the local current center point and the updated center point as the second center point distance d1, and sends the second center point distance d1 to the second participant P0.

[0083] S403: The second participant calculates the sum of the distance between the first center point and the distance between the second center point.

[0084] The second participant calculates the sum of the distance between the first center point d0 and the distance between the second center point d1, that is, d0 + d1. If the sum of the distances is greater than the preset convergence distance, it does not converge and needs to continue iteration; otherwise, it converges and stops iteration.

[0085] The embodiment of the present invention also provides a bilateral horizontal federation security aggregation system based on K-means clustering. Figure 6 is a schematic diagram of the structure of a bilateral horizontal federation security aggregation system based on K-means clustering provided by an embodiment of the present invention, such as Figure 6 As shown, the system includes:

[0086] The initial center point generation module 100 is used for each participant to randomly generate a preset number of initial center points according to the local sample; wherein each participant includes a first participant and a second participant;

[0087] Horizontal federation is often used in scenarios such as loan amount prediction, investment risk analysis, medical data analysis, and market analysis. Both parties involved in horizontal federated learning do not want to share raw data with each other, but need to perform data analysis through aggregated models.

[0088] Taking the market analysis scenario as an example, the two participants are the first retailer P0 and the second retailer P1. The two parties hope to cooperate in market segmentation analysis to better position their marketing strategies. The first retailer P0 has extensive customer purchase data, while the second retailer P1 has detailed customer feedback and survey data. Due to privacy policy and business confidentiality considerations, they do not want to share the original data directly. Therefore, model aggregation is performed to use the obtained aggregated model to identify different customer groups, and to design customized marketing strategies for these groups, such as personalized recommendations, specific discounts, etc., to improve customer satisfaction and sales performance.

[0089] Taking the medical data analysis scenario as an example, the two participants are the first hospital P0 and the second hospital P1. The two parties hope to jointly analyze the health data of patients to study the pathogenesis and treatment effects of specific diseases. Hospital P0 has a large number of electronic health records of patients, while hospital P1 has detailed treatment response data. Due to legal requirements for patient privacy protection, they cannot directly share sensitive patient data. Model aggregation is performed to use the aggregated model to identify specific health characteristics and treatment responses of different patient groups, thereby providing more accurate guidance for clinical treatment, optimizing treatment plans, and improving treatment effects. At the same time, this form of cooperation also helps to accelerate the development of new drugs and treatments.

[0090] In order to achieve model aggregation between the two parties, the data of each participant must first be standardized so that the feature dimensions of both parties are the same. For example, in a medical data analysis scenario, one participant P0 obtains a data set X after data standardization, including m samples, each sample has f features, that is, m patients, each patient has f features (age, gender, disease type, treatment duration, etc.). The other participant P1 obtains a data set Y after data standardization, including n samples, each sample has f features.

[0091] The first participant P1 after standardization has a standardized data set Y with n rows and f columns, and the second participant P0 after standardization has a standardized data set X with m rows and f columns. Assuming there are k categories, k>=2, and the preset number is the number of categories k, then the first participant and the second participant each randomly generate k initial center points.

[0092] The P0 sample ID list is ids_0, the P0 center point: the i-th center point Ci = [Xr0, Xr1, Xr2, ... Xr (f-1)], where i = 0, 1, 2, ..., k-1; r = random.sample (ids_0, k);

[0093] The P1 sample ID list is ids_1, P1 center point: the jth center point Cj = [Yr0, Yr1, Yr2, …Yr(f-1)], where j = 0, 1, 2, …, k-1; r = random.sample(ids_1, k).

[0094] Clustering module 200, used for each participant to cluster according to the distance between the local sample and the current center point to obtain a local clustering result; wherein, in the initial state, the current center point is the initial center point;

[0095] Before the iteration starts, the initial center point is used as the current center point for the first clustering.

[0096] The first participant P1 calculates the Euclidean distance between each sample in its standardized data set and the k current center points respectively, and clusters each sample according to the Euclidean distance, that is, classifies each sample into the category of the current center point closest to it, so as to obtain the local clustering result of the first participant P1.

[0097] The second participant P0 obtains the local clustering result of the second participant in the same manner.

[0098] The center point updating module 300 is used for each participant to update the current center point according to the local clustering result to obtain an updated center point;

[0099] The first participant P1 updates the current center point according to the characteristics of the samples in the local clustering result to obtain an updated center point for each category.

[0100] The second participant P0 obtains the updated center point of the first participant in the same way.

[0101] A distance sum calculation module 400 is used for each participant to calculate the distance sum based on the local current center point and the updated center point;

[0102] Afterwards, the two participants calculate the center point distance based on the local current center point and the updated center point respectively, and calculate the distance sum based on the center point distance of the two parties as a judgment mark for whether the subsequent iterations converge.

[0103] Iteration module 500 is used to judge whether the current iteration converges or reaches the maximum number of iterations based on the distance and. If it converges or reaches the maximum number of iterations, each participant uses the local updated center point to calculate the aggregation model; otherwise, the steps of the clustering module, the center point update module, the distance and calculation module and the iteration module are repeated until the aggregation model is obtained.

[0104] If the sum of the distances is greater than the preset convergence distance, the iteration is considered not to have converged, otherwise the iteration is considered to have converged. In addition, the number of iterations can also be used for judgment. If the current number of iterations reaches the maximum number of iterations, the iteration is considered to have converged, otherwise, it is considered not to have converged.

[0105] If the iteration converges, the two parties use their respective update centers to aggregate the security model of the horizontal federation according to the Paillier encryption protocol to obtain an aggregated model to ensure that data privacy is not leaked.

[0106] If the iteration does not converge, repeat the steps of clustering module, center point update module, distance and calculation module and iteration module, and increase the number of iterations by 1 for each iteration until the iteration converges or reaches the maximum number of iterations, and use the updated center point obtained in the last iteration for safe aggregation to obtain the aggregation model.

[0107] It should be noted that in each iteration, the updated center point needs to be used as the current center point for subsequent calculations.

[0108] As an optional implementation, Figure 7 is a schematic diagram of the structure of the iteration module provided in an embodiment of the present invention, such as Figure 7 As shown, the iteration module includes:

[0109] The encryption submodule 5001 is used for the first participant to generate a public key and a private key, and use the public key to encrypt the local first local model and the first sample volume respectively to obtain the first encrypted local model and the first encrypted sample volume, and send the public key, the first encrypted local model and the first encrypted sample volume to the second participant; wherein the first local model is obtained according to the update center point of the first participant;

[0110] The first participant P1 uses the Paillier encryption protocol to generate a key pair, namely a public key and a private key, and uses the public key to encrypt the local first local model and the first sample amount respectively to obtain the first encrypted local model and the first encrypted sample amount, and sends the public key, the first encrypted local model and the first encrypted sample amount to the second participant P0.

[0111] Aggregation submodule 5002, used for the second participant to use the public key to encrypt the local second local model and the second sample volume respectively, to obtain the second encrypted local model and the second encrypted sample volume, to securely aggregate the first encrypted local model with the second encrypted local model to obtain an encrypted aggregate model, and to securely aggregate the first encrypted sample volume with the second encrypted sample volume to obtain an encrypted aggregate sample volume; wherein the second local model is obtained according to the update center point of the second participant;

[0112] After receiving the public key, the first encrypted local model and the first encrypted sample amount, the second participant P0 uses the public key to encrypt the second local model and the second sample amount to obtain the second encrypted local model and the second encrypted sample amount.

[0113] The two encrypted local models are securely aggregated to obtain an encrypted aggregate model, and the two encrypted sample sizes are aggregated to obtain an encrypted aggregate sample size.

[0114] Blinding submodule 5003, used for the second participant to use random numbers to perform blinding processing on the encrypted aggregation model and the encrypted aggregation sample size, respectively, to obtain the blinded encrypted aggregation model and the blinded encrypted aggregation sample size, and send the blinded encrypted aggregation model and the blinded encrypted aggregation sample size to the first participant;

[0115] The second participant P0 randomly generates two random numbers r0 and r1 in advance, and uses the two random numbers to blind the encryption aggregation model and the encryption aggregation sample size, respectively, to obtain the blind encryption aggregation model and the blind encryption aggregation sample size. The blind encryption aggregation model and the blind encryption aggregation sample size are sent to the first participant P1.

[0116] The decryption submodule 5004 is used for the first participant to use the private key to decrypt the blinded encrypted aggregation model and the blinded encrypted aggregation sample size respectively, to obtain the blinded aggregation model and the blinded aggregation sample size, and to send the blinded aggregation model and the blinded aggregation sample size to the second participant;

[0117] After receiving the blinded encrypted aggregation model and the blinded encrypted aggregation sample size, the first participant P1 decrypts them respectively using the private key to obtain the blinded aggregation model and the blinded aggregation sample size. Afterwards, the blinded aggregation model and the blinded aggregation sample size are sent to the second participant P0.

[0118] The deblinding submodule 5005 is used for the second participant to perform deblinding processing on the blinded aggregation model and the blinded aggregation sample size according to random numbers, obtain the aggregation model, and send the aggregation model to the first participant.

[0119] The second participant P0 de-blinds the aggregation model according to two random numbers to obtain the aggregation model.

[0120] As an optional implementation, the aggregation model = blinded aggregation model / blind aggregation sample size*r1 / r0, and the aggregation model is sent to the first participant P1.

[0121] As an optional implementation, Figure 8 is a schematic diagram of the structure of the clustering module provided in an embodiment of the present invention, such as Figure 8 As shown, the clustering module 200 includes:

[0122] The distance calculation submodule 2001 is used to calculate the Euclidean distance of each local sample relative to all current center points;

[0123] Taking a local sample Xt of the second participant P0 as an example, Xt is a vector with f dimensions, t = [0, 1, 2, …, m-1], calculate the Euclidean distance between the sample Xt and a central point Ci dti = sqrt((Xt0-Xr0)^2+(Xt1-Xr1)^2+…+(Xt(f-1)-Xr(f-1))^2).

[0124] Calculate the Euclidean distance between each local sample in the second participant P0 and all current center points in the above way, and generate the distance dataset D mk :

[0125]

[0126] In the same way, the Euclidean distance between each local sample in the first participant P1 and the current center point is calculated, and the distance dataset D is generated. nk :

[0127]

[0128] The clustering submodule 2002 is used to classify each local sample into the category corresponding to the current center point with the smallest Euclidean distance to obtain a clustering result.

[0129] Taking the second participant P0 as an example, the distance dataset D of the second participant P0 is mk In , the column index value corresponding to the minimum value of each row is used as the category to which the sample belongs, so as to obtain the clustering result cluster0 of the second participant P0 including k categories. The clustering result cluster1 of the first participant P1 including k categories is obtained in the same way.

[0130] As an optional implementation, Fig. 9 is a schematic diagram of the structure of the central point update module provided in an embodiment of the present invention, such as Fig. 9 As shown, the central point update module 300 includes:

[0131] The clustering data set generation submodule 3001 is used to form a clustering data set from the local samples of each category in the clustering result;

[0132] The center point updating submodule 3002 is used to calculate the arithmetic mean of each feature in each clustering data set, and use the arithmetic mean of all features as the updated center point of the corresponding category.

[0133] The local samples of the same category in the clustering results are grouped into cluster data sets, and the arithmetic mean of each column feature in each cluster data set is calculated. The array of k rows and f columns formed by combining all the arithmetic mean values ​​is used as the set of updated center points, and each row represents the updated center point of a category.

[0134] As an optional implementation, Fig.10 is a schematic diagram of the structure of the distance and calculation module provided in an embodiment of the present invention, such as Fig.10 As shown, the distance and calculation module 400 includes:

[0135] The first calculation submodule 4001 is used by the second participant to calculate the first center point distance between the local current center point and the updated center point;

[0136] The second participant P0 calculates the Euclidean distance between the local current center point and the updated center point as the first center point distance d0.

[0137] The second calculation submodule 5002 is used for the first participant to calculate the second center point distance between the local current center point and the updated center point, and send the second center point distance to the second participant;

[0138] The first participant P1 calculates the Euclidean distance between the local current center point and the updated center point as the second center point distance d1, and sends the second center point distance d1 to the second participant P0.

[0139] The summing submodule 5003 is used by the second participant to calculate the sum of the distance between the first center point and the distance between the second center point.

[0140] The second participant calculates the sum of the distance between the first center point d0 and the distance between the second center point d1, that is, d0 + d1. If the sum of the distances is greater than the preset convergence distance, it does not converge and needs to continue iteration; otherwise, it converges and stops iteration.

[0141] The above technical solution has the following beneficial effects: by transmitting and analyzing data between two parties, data leakage is ensured and data security is improved; in the process of data security aggregation, encryption and blinding technology are used to ensure that the two parties will not leak the original data to each other during the data transmission process, and will not rely on any third party, nor will the intermediate data be leaked to a third party, further improving security; in the process of security aggregation, only the central point and data volume are encrypted and transmitted, reducing the amount of data transmission, thereby improving data processing efficiency.

[0142] The specific implementation methods of the above invention further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above content is only the specific implementation methods of the present invention and is not intended to limit the protection scope of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A bilateral horizontal federation security aggregation method based on K-means clustering, characterized in that: include: S1. Each participant randomly generates a preset number of initial center points according to a local sample; wherein each participant includes a first participant and a second participant; S2. Each participant clusters according to the distance between the local sample and the current center point to obtain a local clustering result; wherein, in the initial state, the current center point is the initial center point; S3. Each participant updates the current center point according to the local clustering result to obtain an updated center point; S4. Each participant calculates the distance sum based on the local current center point and the updated center point; S5. Determine whether the current iteration converges or reaches the maximum number of iterations based on the distance. If so, each participant uses the local update center point to calculate the aggregation model; otherwise, repeat steps S2-S5 until the aggregation model is obtained.

2. The bilateral horizontal federation security aggregation method based on K-means clustering according to claim 1 is characterized in that: Each participant uses a local update center point to calculate an aggregation model, including: S501, the first participant generates a public key and a private key, and uses the public key to encrypt a local first local model and a first sample amount respectively, to obtain a first encrypted local model and a first encrypted sample amount, and sends the public key, the first encrypted local model and the first encrypted sample amount to the second participant; wherein the first local model is obtained according to the update center point of the first participant; S502, the second participant uses the public key to encrypt the local second local model and the second sample volume respectively, to obtain the second encrypted local model and the second encrypted sample volume, to securely aggregate the first encrypted local model with the second encrypted local model to obtain an encrypted aggregate model, and to securely aggregate the first encrypted sample volume with the second encrypted sample volume to obtain an encrypted aggregate sample volume; wherein the second local model is obtained according to the update center point of the second participant; S503: The second participant uses random numbers to blind the encrypted aggregation model and the encrypted aggregation sample size, respectively, to obtain a blinded encrypted aggregation model and a blinded encrypted aggregation sample size, and sends the blinded encrypted aggregation model and the blinded encrypted aggregation sample size to the first participant; S504: The first participant uses the private key to decrypt the blinded encrypted aggregation model and the blinded encrypted aggregation sample volume respectively to obtain the blinded aggregation model and the blinded aggregation sample volume, and sends the blinded aggregation model and the blinded aggregation sample volume to the second participant; S505: The second participant deblinds the blinded aggregation model and the blinded aggregation sample size according to random numbers to obtain an aggregation model, and sends the aggregation model to the first participant.

3. The bilateral horizontal federation security aggregation method based on K-means clustering according to claim 1 is characterized in that: Each participant clusters the local samples according to the distance between the local samples and the current center point to obtain a local clustering result, including: S201, calculating the Euclidean distance of each local sample relative to all current center points; S202: Classify each local sample into the category corresponding to the current center point with the smallest Euclidean distance to obtain a clustering result.

4. The bilateral horizontal federation security aggregation method based on K-means clustering according to claim 1 is characterized in that: Each participant updates the current center point according to the local clustering result to obtain an updated center point, including: S301, forming a clustering data set from local samples of each category in the clustering result; S302: Calculate the arithmetic mean of each feature in each cluster data set, and use the arithmetic mean of all features as the update center point of the corresponding category.

5. The bilateral horizontal federation security aggregation method based on K-means clustering according to claim 1 is characterized in that: Each participant calculates the distance sum based on the local current center point and the updated center point, including: S401, the second participant calculates the first center point distance between the local current center point and the updated center point; S402, the first participant calculates a second center point distance between the local current center point and the updated center point, and sends the second center point distance to the second participant; S403: The second participant calculates the sum of the distance between the first center point and the distance between the second center point.

6. A bilateral horizontal federation security aggregation system based on K-means clustering, characterized in that: include: An initial center point generation module is used for each participant to randomly generate a preset number of initial center points according to a local sample; wherein each participant includes a first participant and a second participant; The clustering module is used for each participant to cluster according to the distance between the local sample and the current center point to obtain the local clustering result; wherein, the current center point in the initial state is the initial center point; A center point updating module, used for each participant to update the current center point according to the local clustering result to obtain an updated center point; The distance and calculation module is used by each participant to calculate the distance and the distance based on the local current center point and the updated center point; The iteration module is used to judge whether the current iteration converges or reaches the maximum number of iterations based on the distance. If it converges or reaches the maximum number of iterations, each participant uses the local updated center point to calculate the aggregation model; otherwise, the steps of the clustering module, the center point update module, the distance and calculation module and the iteration module are repeated until the aggregation model is obtained.

7. The bilateral horizontal federation security aggregation system based on K-means clustering according to claim 6 is characterized in that: The iteration module includes: An encryption submodule, used for the first participant to generate a public key and a private key, and use the public key to encrypt the local first local model and the first sample volume respectively, to obtain the first encrypted local model and the first encrypted sample volume, and send the public key, the first encrypted local model and the first encrypted sample volume to the second participant; wherein the first local model is obtained according to the update center point of the first participant; An aggregation submodule is used for the second participant to use the public key to encrypt the local second local model and the second sample volume respectively, obtain the second encrypted local model and the second encrypted sample volume, securely aggregate the first encrypted local model with the second encrypted local model to obtain an encrypted aggregate model, and securely aggregate the first encrypted sample volume with the second encrypted sample volume to obtain an encrypted aggregate sample volume; wherein the second local model is obtained according to the update center point of the second participant; A blinding submodule, used for the second participant to use random numbers to blind the encrypted aggregation model and the encrypted aggregation sample size respectively, to obtain a blinded encrypted aggregation model and a blinded encrypted aggregation sample size, and to send the blinded encrypted aggregation model and the blinded encrypted aggregation sample size to the first participant; A decryption submodule, used for the first participant to use the private key to decrypt the blinded encrypted aggregation model and the blinded encrypted aggregation sample size respectively, to obtain the blinded aggregation model and the blinded aggregation sample size, and to send the blinded aggregation model and the blinded aggregation sample size to the second participant; The deblinding submodule is used for the second participant to perform deblinding processing on the blinded aggregation model and the blinded aggregation sample size according to random numbers, obtain the aggregation model, and send the aggregation model to the first participant.

8. The bilateral horizontal federation security aggregation system based on K-means clustering according to claim 6 is characterized in that: The clustering module comprises: The distance calculation submodule is used to calculate the Euclidean distance of each local sample relative to all current center points; The clustering submodule is used to classify each local sample into the category corresponding to the current center point with the smallest Euclidean distance to obtain the clustering result.

9. The bilateral horizontal federation security aggregation system based on K-means clustering according to claim 6, characterized in that: The central point updating module comprises: A clustering dataset generation submodule is used to form a clustering dataset from local samples of each category in the clustering results; The center point update submodule is used to calculate the arithmetic mean of each feature in each clustering data set, and use the arithmetic mean of all features as the updated center point of the category to which it belongs.

10. The bilateral horizontal federation security aggregation system based on K-means clustering according to claim 6, characterized in that: The distance and calculation module comprises: A first calculation submodule, used by the second participant to calculate a first center point distance between a local current center point and an updated center point; A second calculation submodule, used for the first participant to calculate the second center point distance between the local current center point and the updated center point, and send the second center point distance to the second participant; The summation submodule is used by the second participant to calculate the sum of the distance between the first center point and the distance between the second center point.

Citation Information

Patent Citations

  • Safe hybrid federal learning framework and method for removing a third party

    CN113689003A

  • Multi-party transverse federation security aggregation method and system and computer storage medium

    CN117852082A

  • FEDERATED LEARNING METHOD FOR k-means CLUSTERING ALGORITHM

    US20220358417A1

  • Method and apparatus for training recognition model, device, and readable storage medium

    WO2021184836A1

  • Decentralized federated clustering method and apparatus, and electronic device and storage medium

    WO2023134070A1