Big data cleaning method and device based on machine learning and homomorphic encryption

By using a combination of machine learning and homomorphic encryption technology in a big data environment, combined with Spark distributed computing and specific algorithms, efficient cleaning and privacy protection of structured data are achieved, solving the low efficiency of data cleaning in the existing technology. and privacy leakage issues.

CN118690378APending Publication Date: 2024-09-24SHAANXI SHUTUHANG INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310283574.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-22
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

Existing data cleaning technology is difficult to effectively clean structured data in a big data environment. At the same time, it lacks privacy protection for sensitive data, leading to the risk of private data leakage.

Method used

Adopt a big data cleaning method based on machine learning and homomorphic encryption, process the data through the Spark distributed computing engine, use the homomorphic encryption algorithm to encrypt and decrypt the data, and combine the TF-IDF and K-Means algorithms to clean the data and remove errors. , missing and duplicate data, and protecting user privacy in the process.

Benefits of technology

It achieves efficient cleaning of structured big data, reduces user operation complexity and time, improves data cleaning efficiency, and effectively protects user privacy data during the cleaning process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118690378A
    Figure CN118690378A
Patent Text Reader

Abstract

The invention discloses a big data cleaning method and device based on machine learning and homomorphic encryption, and the method comprises the steps: obtaining a plurality of data records from a source database, and loading the plurality of data records to a Spark calculation node based on a Spark distributed calculation engine; generating a public key, a private key and a relineation key of a user in the task to be cleaned based on a homomorphic encryption algorithm; null-value data records in the task to be cleaned are removed, then the remaining data records are converted into vectors one by one, and the data records converted into the vectors are encrypted through a public key; carrying out abnormal value detection on each data record, and removing data records which do not pass the abnormal value detection and vectors corresponding to the data records to obtain first processing data; detecting duplicate records in the first processing data, and removing the duplicate records to obtain second processing data; and decrypting the second processing data through the private key. According to the method and the device, the structured big data can be effectively cleaned, and the privacy data of the user can be protected in the data cleaning process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data cleaning, and in particular to a big data cleaning method and device based on machine learning and homomorphic encryption. Background Art

[0002] In the information age, data is a resource. Only reliable and accurate data can accurately reflect the reality and effectively support organizational decision-making. The data in the database exists in multiple business systems. Due to the diversity of business systems, there are erroneous data, missing data or duplicate data in the database. These data are called "dirty data". Data cleaning refers to the process of eliminating "dirty data" in the data, which is the basis for data analysis and management.

[0003] On the one hand, most of the existing technologies use rule-based data cleaning methods, such as the BigDansing system or the NADEEF system. The above systems all support users to define data cleaning rules based on functional dependencies and negative dependencies, and then use these rules to detect errors in the data set. This cleaning method is based on relational algebra knowledge, which requires a high level of theoretical knowledge from users, is not suitable for ordinary users, and has low usability.

[0004] In addition, in the prior art, data cleaning is also performed by editing rules. Specifically, editing rules use relational master data and interaction with users to perform data cleaning. Among them, master data refers to high-quality data that describes business entities in an enterprise. The cleaning effect of this method depends on the accuracy of the master data. If the accuracy of the master data cannot be guaranteed, the cleaning effect of this method will be greatly affected. At the same time, this cleaning method also requires users to master a wealth of relevant knowledge in the field of data association. However, in a big data environment, data sources are diverse. As the amount of data continues to grow, user-defined rules will continue to increase. The master data relied on needs to be updated in a timely manner to ensure the correctness of the master data, which makes the data cleaning process more and more difficult.

[0005] On the other hand, privacy data leakage incidents have occurred frequently in recent years, causing serious impacts on users. The most leaked privacy data is the user's basic personal information, followed by user account and password information, and then individual sensitive information. However, most of the existing data cleaning technologies do not consider the user's privacy protection. The data cleaning process involves data input, calculation and output stages, which all have security risks of privacy data leakage.

[0006] Therefore, the prior art lacks a data cleaning method that can both effectively clean big data and protect sensitive data. Summary of the invention

[0007] In order to make up for the shortcomings of the prior art, the present invention provides a big data cleaning method and device based on machine learning and homomorphic encryption, which can not only effectively clean structured big data, but also protect the user's privacy data during the data cleaning process.

[0008] In order to achieve the above object, the present invention adopts the following technical scheme: In a first aspect, the present invention provides a big data cleaning method based on machine learning and homomorphic encryption, which is applied to a server of a computer, and the method comprises: Obtain a configuration file of a task to be cleaned, and parse configuration items in the configuration file; the configuration items include data source configuration items, cleaning configuration items, and target database configuration items; the data source configuration items include configuration items of a source database, and the source database includes multiple data records that need to be cleaned; the source database is a relational database, and the data records are relational data; the target database configuration items include configuration items of the target database; Acquire the plurality of data records from the source database, and load the plurality of data records onto a Spark computing node based on a Spark distributed computing engine; Generate the public key, private key and relinearization key of the user in the task to be cleaned based on the homomorphic encryption algorithm; Removing data records with null values ​​in the tasks to be cleaned, and then converting the remaining data records into vectors one by one, and encrypting the data records converted into vectors by using the public key, and relinearizing the encryption process by using the relinearization key; Performing outlier detection on the data records corresponding to each encrypted vector, and removing the data records that fail the outlier detection and their corresponding vectors to obtain first processed data; Detecting duplicate records in the first processed data and removing the duplicate records to obtain second processed data; the duplicate records include completely identical vectors and vectors whose similarity meets a preset threshold; The second processed data is decrypted by the private key, and the decrypted data is output to the target database.

[0009] In a possible implementation, converting the remaining data records into vectors one by one specifically includes: For each of the data records, a vector is initialized one by one; Obtaining a numeric field in the data record, and copying the value of the numeric field to the corresponding vector; Obtain a date field in the data record, convert the date field into a TIMESTAMP type and add the converted date field to the vector; A character field in the data record is obtained, the text contained in the character field is converted into a word frequency vector of the character field by using a TF-IDF algorithm, and the word frequency vector is added to the vector.

[0010] In a possible implementation, the converting the text contained in the character field into a word frequency vector of the character field by using the TF-IDF algorithm specifically includes: Traversing all the data records, and segmenting the values ​​of the character fields in all the data records to obtain a word set; Calculate the frequency of each word in the set appearing in the data record to obtain the word frequency of each word; For each word in the set, obtain the total number of records of each word in all the data records and the number of data records containing the word; Calculate the inverse document frequency of the word according to the total number of records of the word and the number of data records containing the word; Calculate the product of the term frequency and the inverse document frequency of each word in the set; The text of each word obtained according to the product is converted into a word frequency vector of the character field.

[0011] In a possible implementation, outlier detection is performed on the data records corresponding to each encrypted vector, and the data records and their corresponding vectors that fail the outlier detection are removed, specifically including: Obtain a field of a numerical type in each decrypted vector, and calculate the quartiles of the field, which are respectively denoted as Q1 and Q3; Calculate the difference between Q1 and Q3 to obtain the interquartile range, recorded as IQR; Calculate the threshold range of the field according to the quartile and the quartile difference; the threshold range is Q1-1.5*IQR~Q3+1.5*IQR; It is determined whether the value of the field is within a threshold range. If not, it is considered that the vector where the field is located has failed the outlier detection, and the vector where the field is located and its corresponding data record are removed.

[0012] In a possible implementation manner, the detecting duplicate records in the first processed data and removing the duplicate records specifically includes: Identifying and removing identical data records in the first processed data through a Spark built-in function of the Spark computing node; Using the K-Means clustering algorithm of the Spark computing node, each vector in the first processed data is divided into clusters represented by the centroid closest to the vector; The inertia of all the clusters is calculated, the cluster with the smallest inertia is selected, and the similarities of the vectors contained in the clusters are compared by a cosine similarity algorithm, and the vectors whose similarities meet a preset threshold are removed.

[0013] In a possible implementation, the dividing each vector in the first processed data into a cluster represented by a centroid closest to the vector by using the K-Means clustering algorithm of the Spark computing node specifically includes: Initializing the parameters of the K-Means clustering algorithm; the parameters include the maximum number of iterations; Randomly select multiple centroids; Calculate the Euclidean distance from each vector in the first processed data to each centroid using the public key and the relinearization key, and divide each vector into a cluster represented by a centroid closest to the vector; Calculate the new centroid of each cluster after division using the public key and the relinearization key; The above calculation process is repeatedly performed until the new centroid of the cluster is the same as the centroid calculated last time, or the number of repetitions meets the maximum number of iterations.

[0014] In a possible implementation, parsing the configuration items in the configuration file specifically includes: Obtain the source database IP address, source database port number, source database user name and source database password from the configuration items of the source database; obtain the target database IP address, target database port number, target database user name and target database password from the target database, and generate a URL address based on the above-obtained data; The URL address and the Java language database connection are used to establish connections with the source database and the target database respectively.

[0015] In a second aspect, the present invention provides a big data cleaning device based on machine learning and homomorphic encryption, which is applied to a server of a computer, and the device comprises: A parsing module, used to obtain a configuration file of a task to be cleaned, and parse configuration items in the configuration file; the configuration items include data source configuration items, cleaning configuration items, and target database configuration items; the data source configuration items include configuration items of a source database, and the source database includes a plurality of data records to be cleaned; the source database is a relational database, and the data records are relational data; the target database configuration items include configuration items of the target database; A first processing module, configured to obtain the plurality of data records from the source database, and load the plurality of data records onto a Spark computing node based on a Spark distributed computing engine; The second processing module is used to generate the public key, private key and relinearization key of the user in the task to be cleaned based on the homomorphic encryption algorithm; A third processing module is used to remove the data records with null values ​​in the tasks to be cleaned, and then convert the remaining data records into vectors one by one, and encrypt the data records converted into vectors by using the public key, and relinearize the encryption process by using the relinearization key; a fourth processing module, configured to perform outlier detection on the data records corresponding to each encrypted vector, and remove the data records and their corresponding vectors that fail the outlier detection, to obtain first processed data; a fifth processing module, configured to detect duplicate records in the first processed data and remove the duplicate records to obtain second processed data; the duplicate records include completely identical vectors and vectors whose similarity meets a preset threshold; The sixth processing module is used to decrypt the second processed data by using the private key and output the decrypted data to the target database.

[0016] In a third aspect, the present invention provides an electronic device, comprising a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement any of the above-mentioned big data cleaning methods based on machine learning and homomorphic encryption.

[0017] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement any of the above-mentioned big data cleaning methods based on machine learning and homomorphic encryption.

[0018] The big data cleaning method based on machine learning and homomorphic encryption provided by the embodiment of the present invention cleans the relational data extracted from the database, divides the data to be cleaned into data errors, data missing and data duplication, performs outlier detection on the data and removes records with data errors in the data, detects and filters out records containing null values ​​in the data to be cleaned, identifies and removes duplicate records in the data to be cleaned. The present invention can not only effectively clean structured big data, but also encrypts the user's privacy data using a homomorphic encryption algorithm during the data cleaning process, thereby protecting the user's privacy during the data cleaning process.

[0019] The present invention is based on machine learning technology and can clean data without excessive human participation, which not only improves the efficiency of data cleaning but also reduces the user's operation time and operation complexity.

[0020] The present invention utilizes the distributed computing capability provided by Spark, which not only supports data cleaning operations in big data scenarios, but also can utilize the parallel computing capability of multiple computing nodes of Spark to calculate large amounts of data, further improving data cleaning efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 A flowchart of a method for cleaning big data based on machine learning and homomorphic encryption provided by an embodiment of the present invention; Figure 2 An overall flow chart of a big data cleaning method based on machine learning and homomorphic encryption provided by an embodiment of the present invention; Figure 3 A data extraction flow chart of a big data cleaning method based on machine learning and homomorphic encryption provided in an embodiment of the present invention; Figure 4 A data cleaning flow chart of a big data cleaning method based on machine learning and homomorphic encryption provided in an embodiment of the present invention; Figure 5 A structural block diagram of a big data cleaning device based on machine learning and homomorphic encryption provided in an embodiment of the present invention. Implementation

[0022] 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.

[0023] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, "multiple" means two or more. In addition, the use of "based on" or "according to" means openness and inclusiveness, because the process, steps, calculations or other actions "based on" or "according to" one or more of the conditions or values ​​may be based on additional conditions or values ​​beyond the described values ​​in practice.

[0024] The embodiments of the present invention provide a big data cleaning method and device based on machine learning and homomorphic encryption, which can not only effectively clean structured big data, but also protect the user's privacy data during the data cleaning process.

[0025] like Figure 1 and Figure 2 As shown, a big data cleaning method based on machine learning and homomorphic encryption is applied to a computer server, and the method includes: S1. Obtain the configuration file of the task to be cleaned and parse the configuration items in the configuration file.

[0026] Among them, the configuration items include data source configuration items, cleaning configuration items and target database configuration items; the data source configuration items include configuration items of the source database, and the source database includes multiple data records that need to be cleaned; the source database is a relational database, and the data records are relational data; the target database configuration items include configuration items of the target database.

[0027] The user uploads the configuration file through the Web browser, and the present invention reads the configuration file of the task to be cleaned uploaded by the user through the server of the computer. In other words, the user needs to create a JSON configuration file for each task to be cleaned.

[0028] The configuration items in the configuration file include data source configuration items, cleaning configuration items, and target database configuration items.

[0029] Specifically, the data source configuration items include user name, data cleaning task name, source database IP and port, source database user name and password, table name to be cleaned, source table primary key, and number of partitions, etc.

[0030] The cleaning configuration items include outlier detection configuration, null value filtering configuration, data deduplication configuration and custom cleaning configuration.

[0031] Among them, the outlier detection configuration includes the enable field configuration; when the enable field is configured to true, outlier detection is performed and the result is used as the input for null value filtering. Otherwise, outlier detection is not performed and null value filtering is performed directly. The default value is true.

[0032] The null value filtering configuration includes the enable field configuration and the blank_values ​​field configuration. When the enable field is true, null value filtering is performed and the result is used as the input for data deduplication. Otherwise, null value filtering is not performed and data deduplication is performed directly. The default value is true. The blank_values ​​field is an array type and some null value formats need to be pre-defined. Users can add custom null values ​​through the blank_values ​​field. This field is only enabled when the enable field is true.

[0033] Data deduplication configuration includes enable field configuration, n_cluster field configuration, and threshold field configuration. When the enable field is true, data deduplication is performed and the result is used as the input of custom cleaning or directly output. Otherwise, data deduplication is not performed. The default value is true. The n_cluster field indicates the number of clusters in the K-Means algorithm, which is also the number of centroids. The default value is the total number of records * 0.1. The threshold field is used for the similarity threshold of deduplication. The default value is 0.9.

[0034] The custom cleaning configuration includes an array, and each array element is called a custom cleaning step. A custom cleaning step is an object composed of three fields: input_table field, output_table field and action field. Among them, the input_table field is the input table name. After the abnormal value detection configuration, the null value filtering configuration and the data deduplication configuration, the set of records will form a data table in the memory. The value of this field is the name of the table defined by the user; the output_table field is the output table name, and the value of this field is the table name of the data table after the custom cleaning is completed; the action field is the cleaning operation, which is an SQL statement. The user can define this field to customize the cleaning strategy. For users who are not familiar with the SQL language, the present invention also provides a visual operation interface. The user can configure the cleaning operation according to each field, wherein the cleaning operation includes: the numerical type supports greater than, less than, not equal to, greater than or equal to, and less than or equal to operations, the character type supports case conversion, removal of invalid characters at the beginning and end, and character replacement operations, and the server can convert these configurations into SQL statements in the action field.

[0035] For the above cleaning configuration items, the server of the present invention can also verify the above configuration items through preset verification rules. The preset verification rules include: first, the threshold field must be between 0 and 1; second, the n_cluster field must be between 0 and the total number of records; third, in the custom cleaning configuration, the output_table field of the previous array element must be the same as the input_table field of the next array element. If the configuration items obtained by the server do not meet the requirements, the configuration verification failure information is returned to the Web browser, prompting the user that the configuration verification failed and needs to be reconfigured.

[0036] The target database configuration items include the target database IP address, port number, target database user name and password, and target table name.

[0037] S2. Obtain multiple data records from the source database, and load the multiple data records onto the Spark computing node based on the Spark distributed computing engine.

[0038] Among them, the Spark distributed computing engine is a general-purpose big data analysis engine that integrates batch processing, streaming query and interactive query.

[0039] Specifically, firstly, the present invention is based on the Spark distributed computing engine. The server calls the script file to start the Spark computing node and the task server, and obtains the historical tasks submitted to the Spark cluster and the currently running tasks by querying the task server, and returns the task information to the Web browser.

[0040] Secondly, the full table data, that is, the relational data in the source database, is extracted through SQL query statements, and the extracted data records are loaded into the memory of the Spark computing node according to the number of partitions provided by the user. Specifically, the data of the source database and the source table in the source database are extracted into the memory through SQL query statements to form table T; and partitioned according to the number of partitions provided by the user, different nodes obtain data from different partitions, to prevent all data from being loaded into the same node, resulting in an Out of Memory error, which in turn causes the cleaning task to fail.

[0041] Again, the function used for data cleaning is registered as a UDF (User-Define Function) so that the function can be used in the SQL statement of Spark SQL. Specifically, the present invention implements the functions filter_none(), check_anomaly() and dedup() for null value filtering, outlier detection and data deduplication in the cleaning step based on machine learning technology. Before performing the encryption and cleaning steps, the three functions are registered as UDF (User-Define Function) in Spark SQL so that Spark SQL can use this function in the SQL statement for data cleaning.

[0042] Finally, submit the cleaning task to the Spark cluster, save the current task status to the business database, start the polling thread, regularly send requests to the task server, obtain the status of the current cleaning task, and return the task information to the user. Specifically, submit the cleaning task to the Spark cluster, save the name, start time, and corresponding user name of the current cleaning task in the business database, set the running status of the cleaning task to RUNNING, start the polling thread, and regularly send requests to the task server to obtain the status of the current cleaning task. If the status obtained is FINISH or KILLED, the end or failure of the cleaning task will be returned to the user respectively. S3. Generate the public key, private key and relinearizationkey of the user in the task to be cleaned based on the homomorphic encryption algorithm.

[0043] Among them, the homomorphic encryption algorithm refers to the process of homomorphically encrypting the original data, performing specific operations on the obtained ciphertext, and then homomorphically decrypting the calculation result. The obtained plaintext is equivalent to the data result obtained by directly performing the same calculation on the original plaintext data.

[0044] In the present invention, for the fields specified by the user that contain private data, the present invention generates a public key and a private key for the user in advance, and encrypts the data records in the acquired source database with the public key before data cleansing. Due to the inherent characteristics of homomorphic encryption technology, the results of calculation operations based on ciphertext and calculation operations based on plaintext are the same, so the present invention uses homomorphic encryption technology to prevent the leakage of user privacy data while performing data cleansing.

[0045] S4. Remove the data records with null values ​​in the task to be cleaned, and then convert the remaining data records into vectors one by one, and encrypt the data records converted into vectors through the public key, and relinearize the encryption process through the relinearization key.

[0046] Among them, the data records with null values ​​in the task to be cleaned are removed, that is, whether the data record contains null values ​​is detected, and if the data record contains NULL or a string with an empty meaning, the record is removed.

[0047] The remaining data records are converted into vectors one by one. This is because the records in the database cannot be directly used as input for the machine learning algorithm. The present invention uniformly converts all fields of the data records into numerical data, and then combines all numerical data into vectors after processing, and makes each record correspond to a vector.

[0048] S5. Perform outlier detection on the data records corresponding to each encrypted vector, and remove the data records that fail the outlier detection and their corresponding vectors to obtain first processed data.

[0049] Specifically, all TINYINT, SMALLINT, MEDIUMINT, INT, DOUBLE, and FLOAT numeric fields in the data records are traversed, and outlier detection is performed on the data in the above fields, and all data records that fail the outlier detection and their corresponding vectors are removed.

[0050] S6. Detect duplicate records in the first processed data and remove the duplicate records to obtain second processed data; the duplicate records include completely identical vectors and vectors whose similarity meets a preset threshold.

[0051] Among them, data duplication refers to the same data appearing multiple times in a database instance, that is, there is duplication between data. Data duplication can refer to all attributes between two records being completely consistent, or it can refer to the case where all attributes are not completely consistent, but the two records represent the same entity in the real world. In this case, the similarity between the two records is often very high. For example, a record in the database is ("1 MOBILE LIMITED", "30 CITY ROAD", "London"), and another record is ("1 MOBILE Ltd.","30 CITY RD" ,"LONDON"). These two records are not completely consistent, but they both represent the company 1 MOBILE LIMITED and its location information, so deduplication is required. Such data deduplication is also called Record Linkage, Entity Resolution or Entity Matching. It is a technology for finding records representing the same real-world entity in the data source. It is an important step in data cleaning and can eliminate duplicate records in the database.

[0052] Specifically, we first use the built-in function of Spark to remove completely identical data, and then remove data that is not completely identical but represents the same entity. Therefore, we apply the K-Means algorithm to all vectors. We first group the vectors with high similarity into the same cluster through the K-Means algorithm, and then use inertia to measure the cohesion of each cluster. If the cohesion of a cluster is higher, the inertia is smaller, which also means that the vectors in this cluster are more similar, and there is a greater possibility of duplicate data. In a cluster with high cohesion, we calculate the similarity between all vectors in the cluster, and two vectors that exceed the threshold are determined to be duplicate data.

[0053] S7. Decrypt the second processed data using the private key, and output the decrypted data to the target database.

[0054] Specifically, all vectors are decrypted using the user's private key, and the decrypted data records are output to the target database for storage.

[0055] Further, after decrypting the second processed data using the private key, the method further includes: Perform custom wash steps.

[0056] Specifically, traverse the custom cleaning steps, and for each custom cleaning step, run the SQL statement specified by the action field on the table according to the table name specified by the input_table field, and name the output table as the name specified by the output_table field.

[0057] Output the data after custom cleaning.

[0058] Specifically, the user's configuration specifies the IP address, port number, database name, and table name of the target database. If the user does not specify the table name of the target table, the present invention adds the "_cleaned" suffix to the source table name by default as the table name of the target table, and creates the table in the target database, and then uses the append mode to insert the cleaned data into the table. The data cleaning task is returned to the user successfully, and the task status is updated in the business database.

[0059] like Figure 2 and Figure 3 As shown, further, the configuration items in the configuration file are parsed, including: S11. Obtain the source database IP address, source database port number, source database user name and source database password from the configuration items of the source database; obtain the target database IP address, target database port number, target database user name and target database password from the target database, and generate a URL address based on the above obtained data.

[0060] Specifically, the IP address, port number, user name and password of the source database and the target database are obtained by parsing the configuration items in the configuration file, and a URL address is generated according to the above data.

[0061] S12. Connect to the source database and the target database respectively through the URL address and the Java language.

[0062] Specifically, connections are established with the source database and target database through the URL address and JDBC (Java Database Connectivity). If the first connection fails, the server will retry the connection three times. If the connection still fails after the retries, the error message of the connection failure is returned to the user.

[0063] like Figure 2 and Figure 4 As shown, in step S3, the public key, private key and relinearization key of the user in the task to be cleaned are generated based on the homomorphic encryption algorithm, specifically including: S31. Generate the public key and private key of the user in the task to be cleaned based on the homomorphic encryption algorithm, wherein the public key is used to encrypt the data to be cleaned, and the private key is used to decrypt the cleaned data.

[0064] S32, generate a relinearization key. In the present invention, the homomorphic encryption process uses the user public key, but because the size of the multiplication result increases with the number of operations, it is also necessary to use a relinearization key to perform a relinearization process to reduce the size of the operation result.

[0065] S33. The public key, private key and relinearization key are all saved locally and returned to the user at the same time.

[0066] In order to protect user privacy, the present invention utilizes homomorphic encryption technology. Homomorphic encryption is a cryptographic technology based on the computational complexity theory of mathematical problems. It processes homomorphically encrypted data to obtain an output, and decrypts this output, and the result is the same as the output result obtained by processing the unencrypted original data in the same way. Using homomorphic encryption technology, the result obtained by the user after performing an operation on the ciphertext and then decrypting it is consistent with the result obtained by directly operating on the plaintext. This feature allows an untrusted third party to directly operate on the ciphertext without a private key, avoiding the leakage of user sensitive information caused by the need for the third party to decrypt the ciphertext during the operation process.

[0067] Further, in step S4, data records with null values ​​in the task to be cleaned are removed, specifically: null value filtering. There are two main types of null values, one is the NULL value in the source database, and the second is a string with an empty meaning. The null value strings that can be identified by the present invention include (case insensitive): null, "NaN", "", "None", etc. The present invention traverses all the read data records and deletes the data records containing null values.

[0068] Furthermore, in S4, the remaining data records are converted into vectors one by one, specifically including: S41. For each data record r, a vector v is initialized one-to-one.

[0069] S42. Obtain the numeric field in the data record, and copy the value of the numeric field to the corresponding vector v.

[0070] S43, obtaining a date field in the data record, converting the date field to TIMESTAMP type and adding it to the vector. The date field includes DATE, DATETIME, TIME and other fields.

[0071] S44, obtaining a character field in the data record, converting the text contained in the character field into a word frequency vector of the character field using the TF-IDF algorithm, and adding the word frequency vector to the vector. The character field may be a VARCHAR field.

[0072] Specifically, in S44, the text contained in the character field is converted into a word frequency vector of the character field by using the TF-IDF algorithm, which specifically includes: S441. Traverse all data records, and segment the values ​​of character fields in all data records to obtain a set of words.

[0073] S442. Calculate the frequency of each word in the set appearing in the data record to obtain the word frequency TF of each word.

[0074] S443. For each word in the set, obtain the total number of records of each word in all data records and the number of data records containing the word.

[0075] S444: Calculate the inverse document frequency (IDF) of the word based on the total number of records of the word and the number of data records containing the word. Specifically, .

[0076] S445, calculating the product of the term frequency TF and the inverse document frequency IDF of each word in the set; S446. Convert the text of each word obtained by the multiplication into a word frequency vector v1 of a character field, add the word frequency vector v1 to the vector v, and all the vectors v form a vector set V.

[0077] Furthermore, in step S5, outlier detection is performed on the data records corresponding to each encrypted vector, and the data records and their corresponding vectors that fail the outlier detection are removed, which specifically includes: S51. Obtain a field of a numerical type in each decrypted vector, and calculate the quartiles of the field, which are recorded as Q1 and Q3 respectively.

[0078] S52. Calculate the difference between Q1 and Q3 to obtain the interquartile range, recorded as IQR.

[0079] S53. Calculate the threshold range of the field according to the quartiles and the interquartile range.

[0080] Among them, the threshold range is Q1-1.5*IQR~Q3+1.5*IQR.

[0081] S54: Determine whether the value of the field is within a threshold range. If not, it is considered that the vector where the field is located has failed the outlier detection, and the vector where the field is located and its corresponding data record are removed.

[0082] Furthermore, detecting duplicate records in the first processed data and removing the duplicate records in S6 specifically includes: S61, identifying and removing identical data records in the first processed data through a Spark built-in function of a Spark computing node; S62, dividing each vector in the first processed data into a cluster represented by a centroid closest to the vector by using a K-Means clustering algorithm of a Spark computing node; S63, calculating the inertia of all clusters, selecting the cluster with the smallest inertia, and comparing the similarities of the vectors contained in the clusters by using a cosine similarity algorithm, and removing the vectors whose similarities meet a preset threshold.

[0083] Inertia is the sum of the mean square distances between each record and the centroid of its cluster, which is an indicator used to measure the degree of cluster cohesion. The smaller the inertia, the higher the degree of cluster cohesion, which means that the records in the cluster are more similar. The cluster with the smallest inertia is selected, and the cosine similarity is used to compare the similarity of the vectors in it. For vectors with similarity greater than the threshold, they are judged as duplicate data and all records except the record with the smallest primary key are deleted.

[0084] S62, dividing each vector in the first processed data into a cluster represented by a centroid closest to the vector by using the K-Means clustering algorithm of the Spark computing node, specifically includes: S621, initializing the parameters of the K-Means clustering algorithm; the parameters include the maximum number of iterations; S622, randomly selecting multiple centroids; S623, calculating the Euclidean distance from each vector in the first processed data to each centroid using the public key and the relinearization key, and dividing each vector into a cluster represented by the centroid closest to the vector; S624, calculating a new centroid of each cluster after division using the public key and the relinearization key; S625, repeat the above calculation process until the new centroid of the cluster is the same as the centroid calculated last time, or the number of repetitions meets the maximum number of iterations.

[0085] In the embodiment of the present invention, for the encrypted vector set V, it is possible to identify and remove vectors that are completely identical in all fields, or to perform a deduplication process based on machine learning. The deduplication process is as follows: First, use Spark built-in functions to remove completely identical data records.

[0086] Secondly, initialize the parameters of the K-Means algorithm. The K-Means algorithm will terminate only when the centroid of each cluster no longer changes, that is, converges. However, when the input data set is a convex data set, it may take more iterative calculations to converge. Therefore, this embodiment sets the maximum number of iterations max_iter to 10. After 10 rounds of iterations, if the data still does not converge, stop clustering and exit the calculation in time.

[0087] Again, the K-Means algorithm is executed.

[0088] Finally, the inertia of all clusters is calculated.

[0089] The big data cleaning method based on machine learning and homomorphic encryption provided by the embodiment of the present invention cleans the relational data extracted from the database, divides the data to be cleaned into data errors, data missing and data duplication, performs outlier detection on the data and removes records with data errors in the data, detects and filters out records containing null values ​​in the data to be cleaned, identifies and removes duplicate records in the data to be cleaned. The present invention can not only effectively clean structured big data, but also encrypts the user's privacy data using a homomorphic encryption algorithm during the data cleaning process, thereby protecting the user's privacy during the data cleaning process.

[0090] The present invention is based on machine learning technology and can clean data without excessive human participation, which not only improves the efficiency of data cleaning but also reduces the user's operation time and operation complexity.

[0091] The present invention utilizes the distributed computing capability provided by Spark, which not only supports data cleaning operations in big data scenarios, but also can utilize the parallel computing capability of multiple computing nodes of Spark to calculate large amounts of data, further improving data cleaning efficiency.

[0092] like Figure 5 As shown, an embodiment of the present invention further provides a big data cleaning device based on machine learning and homomorphic encryption, which is applied to a server of a computer, and the device includes: The parsing module 81 is used to obtain the configuration file of the task to be cleaned and parse the configuration items in the configuration file; the configuration items include data source configuration items, cleaning configuration items and target database configuration items; the data source configuration items include configuration items of the source database, and the source database includes multiple data records to be cleaned; the source database is a relational database, and the data records are relational data; the target database configuration items include configuration items of the target database; A first processing module 82 is used to obtain multiple data records from a source database and load the multiple data records onto a Spark computing node based on a Spark distributed computing engine; The second processing module 83 is used to generate a public key, a private key and a relinearization key of the task to be cleaned based on a homomorphic encryption algorithm; The third processing module 84 is used to remove the data records with null values ​​in the tasks to be cleaned, and then convert the remaining data records into vectors one by one, and encrypt the data records converted into vectors by using the public key, and relinearize the encryption process by using the relinearization key; The fourth processing module 85 is used to perform outlier detection on the data records corresponding to each encrypted vector, and remove the data records that fail the outlier detection and their corresponding vectors to obtain first processed data; The fifth processing module 86 is used to detect duplicate records in the first processed data and remove the duplicate records to obtain second processed data; the duplicate records include completely identical vectors and vectors whose similarity meets a preset threshold; The sixth processing module 87 is used to decrypt the second processed data using the private key and output the decrypted data to the target database.

[0093] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0094] An embodiment of the present invention also provides an electronic device, which includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by the processor to implement the big data cleaning method based on machine learning and homomorphic encryption in the embodiment of the present invention.

[0095] An embodiment of the present invention also provides a computer-readable storage medium, which stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the big data cleaning method based on machine learning and homomorphic encryption in an embodiment of the present invention.

[0096] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the process or function according to the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that can be accessed by the computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0097] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A big data cleaning method based on machine learning and homomorphic encryption, characterized in that: Applied to a server side of a computer, the method comprises: Obtain a configuration file of a task to be cleaned, and parse configuration items in the configuration file; the configuration items include data source configuration items, cleaning configuration items, and target database configuration items; the data source configuration items include configuration items of a source database, and the source database includes multiple data records that need to be cleaned; the source database is a relational database, and the data records are relational data; the target database configuration items include configuration items of the target database; Acquire the plurality of data records from the source database, and load the plurality of data records onto a Spark computing node based on a Spark distributed computing engine; Generate the public key, private key and relinearizationkey of the user in the task to be cleaned based on the homomorphic encryption algorithm; Remove the data records with null values ​​in the task to be cleaned, then convert the remaining data records into vectors one by one, encrypt the data records converted into vectors by using the public key, and relinearize the encryption process by using the relinearizationkey; Performing outlier detection on the data records corresponding to each encrypted vector, and removing the data records that fail the outlier detection and their corresponding vectors to obtain first processed data; Detecting duplicate records in the first processed data and removing the duplicate records to obtain second processed data; the duplicate records include completely identical vectors and vectors whose similarity meets a preset threshold; The second processed data is decrypted by the private key, and the decrypted data is output to the target database.

2. The method according to claim 1, characterized in that The remaining data records are converted into vectors one by one, specifically including: For each of the data records, a vector is initialized one by one; Obtaining a numeric field in the data record, and copying the value of the numeric field to the corresponding vector; Obtain a date field in the data record, convert the date field into a TIMESTAMP type and add the converted date field to the vector; A character field in the data record is obtained, the text contained in the character field is converted into a word frequency vector of the character field by using a TF-IDF algorithm, and the word frequency vector is added to the vector.

3. The method according to claim 2, characterized in that The converting the text contained in the character field into a word frequency vector of the character field by using the TF-IDF algorithm specifically includes: Traversing all the data records, and segmenting the values ​​of the character fields in all the data records to obtain a word set; Calculate the frequency of each word in the set appearing in the data record to obtain the word frequency of each word; For each word in the set, obtain the total number of records of each word in all the data records and the number of data records containing the word; Calculate the inverse document frequency of the word according to the total number of records of the word and the number of data records containing the word; Calculate the product of the term frequency and the inverse document frequency of each word in the set; The text of each word obtained according to the product is converted into a word frequency vector of the character field.

4. The method according to claim 1, characterized in that: Performing outlier detection on the data records corresponding to each encrypted vector, and removing the data records and their corresponding vectors that fail the outlier detection, specifically includes: Obtain a field of a numerical type in each decrypted vector, and calculate the quartiles of the field, which are respectively denoted as Q1 and Q3; Calculate the difference between Q1 and Q3 to obtain the interquartile range, recorded as IQR; Calculate the threshold range of the field according to the quartile and the quartile difference; the threshold range is Q1-1.5*IQR~Q3+1.5*IQR; It is determined whether the value of the field is within a threshold range. If not, it is considered that the vector where the field is located has failed the outlier detection, and the vector where the field is located and its corresponding data record are removed.

5. The method according to claim 1, characterized in that The detecting duplicate records in the first processed data and removing the duplicate records specifically includes: Identifying and removing identical data records in the first processed data through a Spark built-in function of the Spark computing node; Using the K-Means clustering algorithm of the Spark computing node, each vector in the first processed data is divided into clusters represented by the centroid closest to the vector; The inertia of all the clusters is calculated, the cluster with the smallest inertia is selected, and the similarities of the vectors contained in the clusters are compared by a cosine similarity algorithm, and the vectors whose similarities meet a preset threshold are removed.

6. The method according to claim 5, characterized in that The dividing each vector in the first processed data into a cluster represented by a centroid closest to the vector by the K-Means clustering algorithm of the Spark computing node specifically includes: Initializing the parameters of the K-Means clustering algorithm; the parameters include the maximum number of iterations; Randomly select multiple centroids; Calculate the Euclidean distance from each vector in the first processed data to each centroid using the public key and the relinearization key, and divide each vector into a cluster represented by a centroid closest to the vector; Calculate the new centroid of each cluster after division using the public key and the relinearization key; The above calculation process is repeatedly performed until the new centroid of the cluster is the same as the centroid calculated last time, or the number of repetitions meets the maximum number of iterations.

7. The method according to claim 1, characterized in that The parsing of the configuration items in the configuration file specifically includes: Obtain the source database IP address, source database port number, source database user name and source database password from the configuration items of the source database; obtain the target database IP address, target database port number, target database user name and target database password from the target database, and generate a URL address based on the above-obtained data; The URL address and the Java language database connection are used to establish connections with the source database and the target database respectively.

8. A big data cleaning device based on machine learning and homomorphic encryption, characterized in that: Applied to a server side of a computer, the device comprises: A parsing module, used to obtain a configuration file of a task to be cleaned, and parse configuration items in the configuration file; the configuration items include data source configuration items, cleaning configuration items, and target database configuration items; the data source configuration items include configuration items of a source database, and the source database includes a plurality of data records to be cleaned; the source database is a relational database, and the data records are relational data; the target database configuration items include configuration items of the target database; A first processing module, configured to obtain the plurality of data records from the source database, and load the plurality of data records onto a Spark computing node based on a Spark distributed computing engine; The second processing module is used to generate the public key, private key and relinearization key of the user in the task to be cleaned based on the homomorphic encryption algorithm; A third processing module is used to remove the data records with null values ​​in the tasks to be cleaned, and then convert the remaining data records into vectors one by one, and encrypt the data records converted into vectors by using the public key, and relinearize the encryption process by using the relinearization key; a fourth processing module, configured to perform outlier detection on the data records corresponding to each encrypted vector, and remove the data records and their corresponding vectors that fail the outlier detection, to obtain first processed data; a fifth processing module, configured to detect duplicate records in the first processed data and remove the duplicate records to obtain second processed data; the duplicate records include completely identical vectors and vectors whose similarity meets a preset threshold; The sixth processing module is used to decrypt the second processed data by using the private key and output the decrypted data to the target database.

9. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the big data cleaning method based on machine learning and homomorphic encryption as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set are loaded and executed by the processor to implement the big data cleaning method based on machine learning and homomorphic encryption as described in any one of claims 1-7.