Database grading method and device, equipment and readable storage medium
By preprocessing and encoding the database data to generate a latent space representation, and combining it with the trained classifier model for prediction, it solves the problem that existing technology cannot cope with unstructured data and complex data types, achieves automated grading, and reduces manual intervention. and improve data governance efficiency.
Patent Information
- Application Number
- CN202410743101.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-09-06
AI Technical Summary
Existing database grading technologies cannot effectively deal with unstructured data and complex data types, relying on predefined rules and requiring a lot of manual intervention.
By obtaining the data of the database to be classified for preprocessing, the encoder is called to encode the data to generate a latent space representation, and the trained classifier model is used to predict the latent space representation to generate a classification result. Specific steps include data missing value processing, error value processing, data deduplication and conversion. The encoder generates mean and logarithmic variance vectors through hidden layer feature extraction and nonlinear transformation. The classifier model is trained through forward propagation and back propagation algorithms. to generate loss values and update parameters.
It realizes automated database classification, reduces manual intervention, can effectively handle unstructured data and complex data types, and improves the efficiency and accuracy of data governance.
Smart Images

Figure CN118606530A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database classification, and in particular to a database classification method, device, equipment, and readable storage medium. Background Art
[0002] With the rapid development of information technology, the amount of data in databases continues to increase, and it is becoming increasingly diversified and complex. This trend is not only reflected in the amount of data, but also in the types and sources of data. For example, enterprises and scientific research institutions need to process not only structured data (such as tabular data in relational databases), but also a large amount of unstructured data (such as text, images, videos, social media content, etc.). These data come from a wide range of sources, including internal enterprise systems, the Internet, IoT devices, etc.
[0003] In this context, safe and standardized governance of this data has become critical for enterprises, scientific research institutions and other organizations. Data governance not only involves data storage and management, but also data security, privacy protection, compliance and data quality management. Effective data governance can help organizations ensure the accuracy, consistency and availability of data, thereby supporting business decisions and innovation.
[0004] However, traditional database data classification and grading methods have some limitations. These methods usually rely on predefined rules and features and require a lot of manual intervention.
[0005] In view of this, this application is filed. Summary of the invention
[0006] The present invention discloses a database grading method, device, equipment, and readable storage medium, aiming to solve the problem that the existing database grading technology cannot cope with unstructured data and complex data types.
[0007] A first embodiment of the present invention provides a database classification method, comprising:
[0008] Acquire a database to be classified, and preprocess the data in the database to be classified;
[0009] Calling an encoder to encode the preprocessed data into distribution parameters of a latent space, and generating a latent space representation according to the distribution parameters of the latent space;
[0010] The trained classifier model is called to predict the latent space representation to generate a classification result of the database to be classified.
[0011] Preferably, the preprocessing includes: data missing value processing, error value processing, data deduplication, and data conversion;
[0012] The data is converted into the following: parsing and reformatting the data, and parsing the data into a json format.
[0013] Preferably, the calling encoder encodes the preprocessed data into distribution parameters of a latent space, and generates a latent space representation according to the distribution parameters of the latent space, specifically:
[0014] The preprocessed data is input into the encoder, and in the forward propagation process, the hidden layer features are extracted and nonlinearly transformed, and the mean vector and the logarithmic variance vector are output in the output layer, wherein the mean vector and the logarithmic variance vector parameterize the conditional distribution of the preprocessed data in the latent variable.
[0015] Preferably, the expression of the encoder is:
[0016] μ(x), log( 2 ()) = Encoder()
[0017] Among them, Encoder(x) is the model of the encoder, μ(x) is the mean of the latent variable z, log( 2 ()) is the logarithmic variance of the latent variable z, and x is the preprocessed data.
[0018] Preferably, the training process of the classifier model is:
[0019] The training data is divided into multiple batches of data, and the classifier model calculates the prediction value of each batch of data through a forward propagation algorithm;
[0020] Compare the predicted value with the true label of the training data, and generate a loss value for each batch of data based on a loss function;
[0021] The back propagation algorithm is used to calculate the gradient of the loss relative to the model parameters of each layer according to the loss value of each batch of data, and the optimizer is used to update the parameters of the classifier model according to the gradient;
[0022] Repeat the above steps until the output of the loss function is less than the preset value.
[0023] Preferably, the loss function is expressed as:
[0024]
[0025] Among them, N is the sample data size, C is the number of categories, and y i,c is the label of attribute category c of sample i, p i,c is the probability that the model predicts that sample i belongs to category c.
[0026] Preferably, it also includes: adding a KL divergence regularization term to the loss function and completing it for optimization when training the classifier model; wherein the calculation formula of KL divergence is as follows:
[0027]
[0028] Among them, q(z|x) is the conditional distribution of the latent space sample z output by the encoder under the original data x, p(z) is the standard normal distribution, K is the dimension size of the latent variable z, is the square of the standard deviation of the ith dimension, is the square of the mean of the ith dimension, is the natural logarithm of the square of the standard deviation of the ith dimension.
[0029] A second embodiment of the present invention provides a database grading device, comprising:
[0030] A preprocessing unit, used for acquiring a database to be classified and preprocessing the data in the database to be classified;
[0031] A latent representation generating unit, configured to call an encoder to encode the preprocessed data into distribution parameters of a latent space, and generate a latent space representation according to the distribution parameters of the latent space;
[0032] The database grading unit is used to call the trained classifier model to predict the latent space representation to generate a grading result of the database to be graded.
[0033] A third embodiment of the present invention provides a database grading device, including a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement a database grading method as described in any one of the above.
[0034] A fourth embodiment of the present invention provides a computer-readable storage medium, characterized in that a computer program is stored therein, and the computer program can be executed by a processor of a device where the computer-readable storage medium is located to implement a database grading method as described in any one of the above items.
[0035] Based on a database grading method, apparatus, device and readable storage medium provided by the present invention, a database to be graded is obtained and the data of the database to be graded is preprocessed; then, an encoder is called to encode the preprocessed data into distribution parameters of a latent space, and a latent space representation is generated according to the distribution parameters of the latent space; finally, a trained classifier model is called to predict the latent space representation to generate a grading result of the database to be graded, thereby solving the problem that the existing database grading technology cannot cope with unstructured data and complex data types. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a flowchart of a database classification method provided by the first embodiment of the present invention;
[0037] Figure 2 It is a module schematic diagram of a database grading device provided by the second embodiment of the present invention. DETAILED DESCRIPTION
[0038] 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.
[0039] In order to better understand the technical solution of the present invention, the embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0040] It should be clear that the described embodiments are only some embodiments of the present invention, not all 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.
[0041] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0042] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0043] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0044] The "first\second" mentioned in the embodiments is only to distinguish similar objects, and does not represent a specific order for the objects. It is understandable that the "first\second" can be interchanged with the specific order or sequence where permitted. It should be understood that the objects distinguished by "first\second" can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than those illustrated or described herein.
[0045] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0046] The present invention discloses a database grading method, device, equipment, and readable storage medium, aiming to solve the problem that the existing database grading technology cannot cope with unstructured data and complex data types.
[0047] The first embodiment of the present invention provides a database grading method, which can be executed by a database grading device (hereinafter referred to as a grading device), and in particular, is executed by one or more processors in the grading device to implement at least the following steps:
[0048] S101, obtaining a database to be classified, and preprocessing the data in the database to be classified;
[0049] In this embodiment, the grading device may be a terminal with data processing capability such as a desktop computer, a laptop computer, a server or a workstation, etc., and the grading device may be installed with a corresponding operating system and application software, and the functions required by this embodiment are realized through the combination of the operating system and the application software;
[0050] It should be noted that in this embodiment, since multiple business types and two common data types are involved, the collected database is first divided into product data database, financial data database, human resources data database, operation data database, and log data database according to the business dimension. According to the type of database, it is a symmetric database or an asymmetric database. The Python database connection library (including but not limited to pymysql, psycopg2, sqlite3) is used to realize data extraction.
[0051] Furthermore, the extracted data can be tested for missing items. To improve data processing efficiency, you can choose to delete records containing missing values, or use methods such as filling and interpolation to process according to specific needs, as well as detect outliers or erroneous data in the data, fill the erroneous data with the last valid value or through other interpolation methods, and determine duplicate data by comparing the unique identifiers (such as ID) and key features (such as name, timestamp) of the data entries, remove duplicate records as needed, retain a copy or merge to retain all useful information. Furthermore, since the data structures of symmetric and asymmetric databases are different, the collected data forms are also different. Scripts are written to parse and reformat data of different structures and convert them into JSON format. Ensure that all data can maintain consistency and operability in subsequent processing.
[0052] S102, calling an encoder to encode the preprocessed data into distribution parameters of a latent space, and generating a latent space representation according to the distribution parameters of the latent space;
[0053] Specifically, in this embodiment, the preprocessed data is input into the encoder, and in the forward propagation process, the hidden layer features are extracted and nonlinearly transformed, and the mean vector and the logarithmic variance vector are output at the output layer, wherein the mean vector and the logarithmic variance vector parameterize the conditional distribution of the preprocessed data in the latent variable;
[0054] It should be noted that the structure of the encoder includes: the input layer is used to pass the original data samples as input to the encoder model. The original data samples can be any form of structured or unstructured data, such as images, text, or other types of data. Data tuples, data tuples are a form of packaging and organizing input data so that it can be processed by the various layers of the encoder. Fully connected hidden layer, the hidden layer uses multiple neurons (the basic computing unit of the neural network) to process the input data. The role of the hidden layer is to extract the features of the input data and represent these features as a new data form, usually through nonlinear transformation. Fully connected layer, this layer further processes the output of the hidden layer to obtain more abstract and useful features. Output layer, the final output layer generates the distribution parameters of the latent space, namely the mean and variance, which are used to represent the distribution of the input data in the latent space, so that the encoder can capture the implicit structure of the data.
[0055] After the input raw data samples are processed by the encoder, they will be mapped to the distribution parameters in the latent space, that is, the conditional distribution of the latent variable. Usually, this distribution is parameterized by the mean and variance and expressed as a Gaussian distribution. Specifically, the encoder formula can be expressed as:
[0056] μ(x), log(2 ()) = Encoder()
[0057] Among them, Encoder(x) is the model of the encoder, μ(x) is the mean of the latent variable z, log( 2 ()) is the logarithmic variance of the latent variable z, and x is the preprocessed data.
[0058] S103, calling the trained classifier model to predict the latent space representation to generate a classification result of the database to be classified.
[0059] In this embodiment, the features extracted by the encoder can be used as input, as well as the corresponding training labels (labels), to train the classifier model. In this process, the classifier model will learn how to associate the input encoded features with the corresponding labels to minimize the loss function of the classification task. The model training steps of the classifier are as follows:
[0060] First, the training data is divided into batches of appropriate size so that the data can be processed in batches while improving the efficiency of training. The batch size can be 32, 64, or 128, etc. For each batch of data, the prediction value of the model can be calculated by the forward propagation algorithm. Specifically, the input data can be fed into the model, propagated layer by layer through each layer of the model, and finally the output of the model is obtained. The predicted value of the model is compared with the true label to calculate the loss value. The loss value reflects the gap between the model prediction result and the true label.
[0061] Next, the back propagation algorithm is used to calculate the gradient of the loss function with respect to the model parameters. The gradient represents the rate of change of the loss function with respect to each model parameter. The back propagation algorithm starts from the output of the loss function and propagates the gradient backward along each layer of the model to adjust the model parameters. This allows the model parameters to be adjusted in the direction of reducing the loss value.
[0062] Based on the calculated gradient, the model parameters are updated using an optimizer (such as stochastic gradient descent (SGD), Adam, etc.). The optimizer adjusts each parameter based on the gradient information so that the loss function gradually decreases. Repeat the above steps and perform multiple iterations of training on all training data until the specified number of training rounds (epochs) is reached or other conditions for stopping training are met (such as the loss value no longer decreases significantly).
[0063] In a possible embodiment of the present invention, the loss function is expressed as:
[0064]
[0065] Among them, N is the sample data size, C is the number of categories, and y i,cis the label of attribute category c of sample i, p i,c is the probability that the model predicts that sample i belongs to category c.
[0066] It should be noted that the cross entropy loss function improves the classification performance of the model by minimizing the gap between the predicted probability and the true label. Specifically, for each sample, the cross entropy loss function calculates the gap between the model's predicted probability and the true label. If the model's predicted probability matches the true label (i.e., p i,c is close to 1, while the p i,c Close to 0), the loss value will be smaller. By averaging the loss values of all samples, the cross entropy loss function can reflect the overall performance of the model on the entire training set. The goal is to minimize this average loss value through the back propagation algorithm to optimize the model parameters.
[0067] In a possible embodiment of the present invention, it further includes: adding a KL divergence regularization term to the loss function and completing it for optimization when training the classifier model; wherein the calculation formula of the KL divergence is as follows:
[0068]
[0069] Among them, q(z|x) is the conditional distribution of the latent space sample z output by the encoder under the original data x, p(z) is the standard normal distribution, K is the dimension size of the latent variable z, is the square of the standard deviation of the ith dimension, is the square of the mean of the ith dimension, is the natural logarithm of the square of the standard deviation of the ith dimension.
[0070] It should be noted that by adding the KL divergence regularization term to the loss function, the potential space distribution of the encoder output can be effectively constrained to be closer to the standard normal distribution. This regularization method can not only improve the stability and generalization ability of the model, but also avoid the overly dispersed or concentrated distribution in the latent space, thereby enhancing the adaptability of the model on various data.
[0071] See also Figure 2 A second embodiment of the present invention provides a database classification device, comprising:
[0072] The pre-processing unit 201 is used to obtain the database to be classified and pre-process the data in the database to be classified;
[0073] A latent representation generating unit 202, configured to call an encoder to encode the preprocessed data into distribution parameters of a latent space, and generate a latent space representation according to the distribution parameters of the latent space;
[0074] The database grading unit 203 is used to call the trained classifier model to predict the latent space representation to generate a grading result of the database to be graded.
[0075] A third embodiment of the present invention provides a database grading device, including a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement a database grading method as described in any one of the above.
[0076] A fourth embodiment of the present invention provides a computer-readable storage medium, characterized in that a computer program is stored therein, and the computer program can be executed by a processor of a device where the computer-readable storage medium is located to implement a database grading method as described in any one of the above items.
[0077] Based on a database grading method, apparatus, device and readable storage medium provided by the present invention, a database to be graded is obtained and the data of the database to be graded is preprocessed; then, an encoder is called to encode the preprocessed data into distribution parameters of a latent space, and a latent space representation is generated according to the distribution parameters of the latent space; finally, a trained classifier model is called to predict the latent space representation to generate a grading result of the database to be graded, thereby solving the problem that the existing database grading technology cannot cope with unstructured data and complex data types.
[0078] Exemplarily, the computer program described in the third embodiment and the fourth embodiment of the present invention can be divided into one or more modules, and the one or more modules are stored in the memory and executed by the processor to complete the present invention. The one or more modules can be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program in the hierarchical device for implementing a database. For example, the device described in the second embodiment of the present invention.
[0079] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the database classification method, and uses various interfaces and lines to connect the various parts of the entire database classification method.
[0080] The memory can be used to store the computer program and / or module, and the processor realizes various functions of a database classification method by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, a text conversion function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, text message data, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Med i aCard, SMC), a secure digital (Secure Digital, SD) card, a flash card (F l ash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0081] Wherein, if the implemented module is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0082] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.
[0083] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art 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 database classification method, characterized in that: include: Acquire a database to be classified, and preprocess the data in the database to be classified; Calling an encoder to encode the preprocessed data into distribution parameters of a latent space, and generating a latent space representation according to the distribution parameters of the latent space; The trained classifier model is called to predict the latent space representation to generate a classification result of the database to be classified.
2. A database grading method according to claim 1, characterized in that: The preprocessing includes: data missing value processing, error value processing, data deduplication, and data conversion; The data is converted into parsed and reformatted data, and uniformly parsed into json format.
3. A database grading method according to claim 1, characterized in that: The calling encoder encodes the preprocessed data into distribution parameters of the latent space, and generates a latent space representation according to the distribution parameters of the latent space, specifically: The preprocessed data is input into the encoder, and in the forward propagation process, the hidden layer features are extracted and nonlinearly transformed, and the mean vector and the logarithmic variance vector are output in the output layer, wherein the mean vector and the logarithmic variance vector parameterize the conditional distribution of the preprocessed data in the latent variable.
4. A database grading method according to claim 3, characterized in that: The expression of the encoder is: μ(x), log(σ 2 (x))=Encoder(x) Among them, Encoder(x) is the model of the encoder, μ(x) is the mean of the latent variable z, log(σ 2 (x)) is the logarithmic variance of the latent variable z, and x is the preprocessed data.
5. A database grading method according to claim 1, characterized in that: The training process of the classifier model is: The training data is divided into multiple batches of data, and the classifier model calculates the prediction value of each batch of data through a forward propagation algorithm; Compare the predicted value with the true label of the training data, and generate a loss value for each batch of data based on a loss function; The back propagation algorithm is used to calculate the gradient of the loss relative to the model parameters of each layer according to the loss value of each batch of data, and the optimizer is used to update the parameters of the classifier model according to the gradient; Repeat the above steps until the output of the loss function is less than the preset value.
6. A database grading method according to claim 5, characterized in that: The expression of the loss function is: Among them, N is the sample data size, C is the number of categories, and y i,c is the label of attribute category c of sample i, p i,c is the probability that the model predicts that sample i belongs to category c.
7. A database grading method according to claim 6, characterized in that: Also includes: The KL divergence regularization term is added to the loss function and completed for optimization when training the classifier model; wherein the calculation formula of KL divergence is as follows: Among them, q(z|x) is the conditional distribution of the latent space sample z output by the encoder under the original data x, p(z) is the standard normal distribution, K is the dimension size of the latent variable z, is the square of the standard deviation of the ith dimension, is the square of the mean of the ith dimension, is the natural logarithm of the square of the standard deviation of the ith dimension.
8. A database grading device, characterized in that: include: A preprocessing unit, used for acquiring a database to be classified and preprocessing the data in the database to be classified; A latent representation generating unit, configured to call an encoder to encode the preprocessed data into distribution parameters of a latent space, and generate a latent space representation according to the distribution parameters of the latent space; The database grading unit is used to call the trained classifier model to predict the latent space representation to generate a grading result of the database to be graded.
9. A database grading device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement a database grading method as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: A computer program is stored, and the computer program can be executed by a processor of the device where the computer-readable storage medium is located to implement a database grading method as described in any one of claims 1 to 7.
