Data processing method and device
By determining the intra-class and inter-class neighborhoods of the sample vector in data processing and calculating divergence, the projection matrix is generated for dimensionality reduction, which solves the problems of excessive data dimensions and poor data processing in multi-cluster categories, and improves the resolution of the local structure and category distinction of the data.
Patent Information
- Application Number
- CN202110319579.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-25
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2041-03-25
AI Technical Summary
In statistical pattern recognition, excessive data dimensions lead to limitations in the practical application of many pattern recognition technologies. Existing dimensionality reduction methods such as LDA are not effective when processing multi-cluster category data.
By obtaining the data to be processed, extracting data features and constructing feature matrix, determining the in-class and inter-class neighborhoods of the sample vector, calculating the in-class divergence and inter-class divergence, generating a projection matrix for dimensionality reduction processing, and obtaining the target feature matrix.
The resolution of local structures in the data is improved, especially in multi-cluster category data, the same category data in the target feature matrix has higher firmness and higher distinction between different categories of data.
Smart Images

Figure CN113780327B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computer technology, specifically to the field of data processing, and more particularly to a method and device for data processing. Background Art
[0002] In statistical pattern recognition, high data dimensionality is the main reason for the practical application limitations of many pattern recognition techniques. In the past few decades, researchers have proposed many dimensionality reduction techniques. LDA (Linear Discriminant Analysis) is one of the current mainstream linear dimensionality reduction methods, which can be applied to the processing of image data and text data.
[0003] In the related technology, the LDA algorithm determines the intra-class divergence based on the sum of the squares of the Euclidean distances between the sample vector and all other sample vectors in the entire sample space, and generates a projection matrix based on this, and then projects the original matrix onto the hyperplane represented by the projection matrix to achieve dimensionality reduction of the original matrix. Summary of the invention
[0004] The embodiments of the present disclosure provide a method and apparatus for data processing.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for data processing, the method comprising: acquiring data to be processed; extracting features of the data, and constructing a feature matrix based on the extracted features, the feature matrix comprising a first preset number of sample vectors pre-labeled with category labels; generating a target feature matrix based on the feature matrix and a predetermined projection matrix, the target feature matrix comprising a second preset number of target vectors, the second preset number being less than the first preset number, the target vector being a projection vector obtained by the sample vector based on the projection matrix; wherein the projection matrix is determined by the following steps: determining the intra-class neighborhood and inter-class neighborhood of each sample vector, wherein the class The inner neighborhood includes sample vectors that are neighbors of the sample vector in the category to which the sample vector belongs, and the inter-class neighborhood includes sample vectors that are neighbors of the sample vector in other categories; based on the inner neighborhood and inter-class neighborhood of each sample vector, the inner-class divergence and inter-class divergence of the feature matrix are determined, the inner-class divergence is the trace of the inner-class divergence matrix of the feature matrix, and the inter-class divergence is the trace of the inter-class divergence matrix of the feature matrix; based on the inner-class divergence and inter-class divergence, a first matrix is generated; the eigenvalue set of the first matrix and the eigenvector corresponding to each eigenvalue are determined; based on the eigenvectors corresponding to the largest second preset number of eigenvalues in the eigenvalue set, a projection matrix is constructed.
[0006] In some embodiments, based on the intra-class neighborhood and inter-class neighborhood of each sample vector, the intra-class divergence and inter-class divergence of the feature matrix are determined, including: half of the sum of the mean of the sum of the squares of the Euclidean distances between each sample vector in the feature matrix and each sample vector in its intra-class neighborhood is determined as the intra-class divergence; half of the sum of the mean of the sum of the squares of the Euclidean distances between each sample vector in the feature matrix and each sample vector in the first neighborhood is determined as the overall divergence of the feature matrix, and the first neighborhood is the union of the intra-class domain and the inter-class neighborhood; the difference between the overall divergence and the intra-class divergence is determined as the inter-class divergence.
[0007] In some embodiments, the first matrix is generated by the following steps: determining the matrix obtained by multiplying the intra-class divergence and the preset weight as the second matrix; determining the difference between the inter-class divergence and the second matrix as the first matrix; wherein the preset weight is the ratio of the inter-class divergence to the intra-class divergence.
[0008] In some embodiments, the second preset number is determined by the following steps: determining the number of feature values in the feature value set that is greater than 0; and determining the number as the second preset number.
[0009] In some embodiments, the method further comprises: ignoring the null space of the overall divergence.
[0010] In a second aspect, an embodiment of the present disclosure further provides a data processing device, which includes: a data acquisition unit, configured to acquire data to be processed; a feature extraction unit, configured to extract features of the data and construct a feature matrix based on the extracted features, the feature matrix including a first preset number of sample vectors pre-labeled with category labels; a feature dimension reduction unit, configured to generate a target feature matrix based on the feature matrix and a predetermined projection matrix, the target feature matrix including a second preset number of target vectors, the second preset number is less than the first preset number, and the target vector is a projection vector obtained by the sample vector based on the projection matrix; wherein the projection matrix is determined by the projection determination unit performing the following steps: determining The intra-class neighborhood and inter-class neighborhood of each sample vector, wherein the intra-class neighborhood includes sample vectors that are neighbors of the sample vector in the category to which the sample vector belongs, and the inter-class neighborhood includes sample vectors that are neighbors of the sample vector in other categories; based on the intra-class neighborhood and inter-class neighborhood of each sample vector, the intra-class divergence and inter-class divergence of the feature matrix are determined, the intra-class divergence is the trace of the intra-class divergence matrix of the feature matrix, and the inter-class divergence is the trace of the inter-class divergence matrix of the feature matrix; based on the intra-class divergence and inter-class divergence, a first matrix is generated; the eigenvalue set of the first matrix and the eigenvector corresponding to each eigenvalue are determined; based on the eigenvectors corresponding to the largest second preset number of eigenvalues in the eigenvalue set, a projection matrix is constructed.
[0011] In some embodiments, the projection determination unit further includes: an intra-class divergence determination module, configured to determine half of the sum of the mean of the sum of the squares of the Euclidean distances between each sample vector in the feature matrix and each sample vector in its intra-class neighborhood as the intra-class divergence; an overall divergence determination module, configured to determine half of the sum of the squares of the Euclidean distances between each sample vector in the feature matrix and each sample vector in the first neighborhood as the overall divergence of the feature matrix, the first neighborhood being the union of the intra-class domain and the inter-class neighborhood; an inter-class divergence determination unit, configured to determine the difference between the overall divergence and the intra-class divergence as the inter-class divergence.
[0012] In some embodiments, the projection determination unit also includes a matrix generation module, which is configured to: determine a matrix obtained by multiplying the intra-class divergence and a preset weight as a second matrix; determine a difference between the inter-class divergence and the second matrix as a first matrix; wherein the preset weight is a ratio of the inter-class divergence to the intra-class divergence.
[0013] In some embodiments, the device further includes a quantity determination unit configured to: determine the number of feature values greater than 0 in the feature value set; and determine the number as a second preset number.
[0014] In some embodiments, the projection determination unit is further configured to: ignore the null space of the overall divergence.
[0015] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by one or more processors, the one or more processors implement the method in any of the above embodiments.
[0016] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable medium having a computer program stored thereon, wherein the program implements the method in any of the above embodiments when executed by a processor.
[0017] The data processing method and device provided by the embodiments of the present disclosure extract features from the acquired data to be processed, and construct a feature matrix based on the extracted features, and then perform dimensionality reduction processing on the feature matrix based on a predetermined projection matrix to obtain a target feature matrix. The projection matrix is determined by the following steps: first, the intra-class neighborhood and inter-class neighborhood of the sample vector are determined, wherein the intra-class neighborhood includes sample vectors that are close neighbors of the sample vector in the same category, and the inter-class neighborhood includes sample vectors that are close neighbors of the sample vector in other categories, and then the intra-class divergence and inter-class divergence of the feature matrix are determined based on the intra-class neighborhood and inter-class neighborhood of each sample vector, so as to determine the projection matrix of the feature matrix. In the dimensionality reduction process, the distance between pairs of sample vectors far away from each other in the same category is avoided, and the distinguishability of the local structure in the data is improved. In particular, when the data of the same category in the data to be processed includes multiple clusters, the compactness of the data of the same category in the target feature matrix is higher, and the distinction between data of different categories is higher. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Other features, objects and advantages of the present disclosure will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0019] Figure 1 is an exemplary system architecture diagram in which some embodiments of the present disclosure may be applied;
[0020] Figure 2 is a flow chart of an embodiment of a method for data processing according to the present disclosure;
[0021] Figure 3 is a flowchart of generating a projection matrix in one embodiment of a method for data processing according to the present disclosure;
[0022] Figure 4 is a flowchart of generating a projection matrix in another embodiment of the data processing method according to the present disclosure;
[0023] Figure 5 is a structural schematic diagram of an embodiment of a data processing device according to the present disclosure;
[0024] Figure 6 It is a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure. DETAILED DESCRIPTION
[0025] The present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.
[0026] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0027] Figure 1 An exemplary system architecture 100 is shown to which the data processing method or data processing apparatus according to the embodiments of the present disclosure can be applied.
[0028] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0029] The user can use the terminal devices 101 , 102 , 103 to interact with the server 105 through the network 104 to receive or send data, etc. For example, the user can send the data to be processed to the server, and can also receive the target feature matrix from the server.
[0030] Terminal devices 101, 102, 103 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be electronic devices with communication functions, including but not limited to smart phones, tablet computers, e-book readers, laptop computers, desktop computers, etc. When terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software or software modules for providing distributed services, or they can be implemented as a single software or software module. No specific limitation is made here.
[0031] For example, the terminal devices 101, 102, and 103 may be loaded with an image recognition model, and the terminal devices 101, 102, and 103 first send the data to be processed to the server 105, and the server 105 performs processing steps such as feature extraction and feature dimension reduction on the data to be processed, and sends the processing results (target feature matrix) to the terminal devices 101, 102, and 103. Then, the terminal devices 101, 102, and 103 input the target feature vector into the image recognition model, and output the image recognition result.
[0032] The server 105 may be a server that provides various services, such as a background data server that processes the data to be processed uploaded by the terminal devices 101, 102, and 103 (e.g., constructs feature evidence based on the data to be processed and performs dimensionality reduction processing). The background data server may pre-process the acquired data to be processed and feed back the processing results (e.g., target feature matrix) to the terminal device.
[0033] It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules for providing distributed services, or it can be implemented as a single software or software module. No specific limitation is made here.
[0034] It should be noted that the data processing method provided in the embodiments of the present disclosure can be executed by the terminal devices 101, 102, 103, or by the server 105. Accordingly, the data processing device can be set in the terminal devices 101, 102, 103, or in the server 105. No specific limitation is made here.
[0035] Continue to refer Figure 2 , shows a process 200 of an embodiment of a method for data processing according to the present disclosure. The method for data processing comprises the following steps:
[0036] Step 201, obtaining data to be processed.
[0037] The data to be processed in this embodiment may include various types of data, such as image data or text data.
[0038] As an example, the execution subject (which may be Figure 1 The server shown in ) can obtain the image captured by the image acquisition device through the network, and then use the acquired image as data to be processed.
[0039] Step 202: extract features of the data and construct a feature matrix based on the extracted features.
[0040] In this embodiment, the feature matrix includes a first preset number of sample vectors pre-labeled with category labels, that is, the dimension of the feature matrix is the first preset number. The category label is used to characterize the category to which the sample points in the feature matrix belong.
[0041] As an example, the data to be processed obtained by the execution subject in step 201 is image data, and the image includes images of multiple faces, and each face corresponds to a category label. The execution subject can extract the value of the pixel from the image and determine the category label of the pixel based on the face to which the pixel belongs. Then, the values of the pixels in each row are arranged in order to obtain a sample vector, and the obtained sample vector set is the feature matrix of the image data. Among them, the dimension of the feature matrix is the number of sample vectors, that is, the number of rows of pixels in the image, and the dimension of the sample vector is the number of pixels in each row in the image.
[0042] In another example, the data to be processed may also be text data, in which category labels may be pre-set based on the subject corresponding to the word, for example, the category label may be set to verb, adjective, noun, etc. according to the attribute of the word. Then, the execution subject may sample m lines of text from the text, extract n words from each line, and determine the category labels corresponding to the n words according to the attribute of the word. The execution subject encodes the n words and arranges them in order to obtain a sample vector, thereby obtaining a feature matrix of the entire text, where the dimension of the feature matrix is m, and the dimension of each sample vector is n.
[0043] Step 203: Generate a target feature matrix based on the feature matrix and a predetermined projection matrix.
[0044] In this embodiment, the target feature matrix includes a second preset number of target vectors, the second preset number is less than the first preset number, and the target vector is a projection vector obtained by the sample vector based on the projection matrix. The target feature matrix represents the feature matrix after dimensionality reduction. Since the projection does not change the category label of the sample point, the sample points in the same target vector all belong to the same category, so the target vector can represent the characteristics of the data to be processed from the dimension corresponding to the category label (i.e., the category).
[0045] The projection matrix represents the hyperplane composed of the projection directions of the feature matrix, each target vector in the projection matrix represents a projection direction, and the dimension of the target vector is the same as the dimension of the sample vector. The second preset number represents the dimension of the projection matrix and the target feature matrix, which can be predetermined according to the dimensionality reduction requirements. In this way, the matrix obtained by left-multiplying the projection matrix by the feature matrix is the target feature matrix.
[0046] In a specific example, the data processing method in this embodiment is used for data preprocessing in an image recognition scenario. The execution subject obtains an image from an image acquisition device as data to be processed, and predetermines a first preset number (for example, it can be 5) and a second preset number (for example, it can be 3). Then the execution subject samples 5 rows of pixels from the image, and extracts the values of 5 sample pixels from each row of pixels. The category label of the sample pixel represents the object to which the pixel belongs (the object can be, for example, a person or an object in the image). The feature matrix obtained in this way includes 5 sample vectors, each sample vector includes 10 sample values, and each sample vector represents the characteristics of a row of pixels in the image. Then the execution subject multiplies the projection matrix by the feature matrix to obtain a target feature matrix. The target feature matrix includes 3 target vectors, each target vector includes 10 sample values. In the target feature matrix, each target vector represents the characteristics of the image data from one dimension. For example, the first column vector can represent the value of the pixel belonging to the first object in the image, and can represent the characteristics of the first object in the image; the second column vector can represent the value of the pixel belonging to the second object in the image, and can represent the characteristics of the second object in the image. Thus, the feature matrix is constructed based on the data to be processed, and the dimension reduction process is performed on the feature matrix. The obtained target feature matrix can be used as the input of the image recognition model for further data processing, such as line recognition.
[0047] In another specific example, the execution subject can obtain the text to be processed from the terminal device, and predetermine a first preset number (for example, it can be 10) and a second preset number (for example, it can be 9). Afterwards, the execution subject can sample 10 lines of text from the text, and extract 5 keywords from each line of text respectively, and then determine the encoding of the keyword in the dictionary as the value of the keyword, so that the feature matrix of the text can be constructed, wherein the feature matrix includes 10 sample vectors, each sample vector includes 5 sample values, each sample vector represents the characteristics of a line of text in the text, and the category label of the sample point can represent the theme of the keyword. Afterwards, the execution subject multiplies the projection matrix by the feature matrix to obtain the target feature matrix, and the target feature matrix includes 9 target vectors, each target vector includes 5 sample values. Moreover, each target vector can represent the keyword characteristics of the text data from the dimension of a subject.
[0048] It is understandable that sample points in the same category may form multiple clusters, so different target vectors can represent the same category label, thereby representing the characteristics of the data to be processed from the same dimension (category).
[0049] Further integration Figure 3 , Figure 3A flowchart of determining a projection matrix in an embodiment of a data processing method of the present disclosure is shown. In the flowchart 300, the following steps are included:
[0050] Step 301: Determine the intra-class neighborhood and inter-class neighborhood of each sample vector.
[0051] In this embodiment, the intra-class neighborhood includes sample vectors in the category to which the sample vector belongs that are close neighbors to the sample vector, and the inter-class neighborhood includes sample vectors in other categories that are close neighbors to the sample vector.
[0052] In the vector space, the vector with the smallest Euclidean distance from the sample vector is called the nearest neighbor of the sample vector. The intra-class neighborhood of the sample vector represents the set of sample points with the smallest distance in the same category, that is, a cluster formed by data in the same category in the data to be processed. The inter-class neighborhood represents the set of sample points with the smallest distance between different categories, that is, a cluster formed by data between different categories in the data to be processed.
[0053] As an example, for sample vectors A, B, C, D, E, and F belonging to the same category, if the Euclidean distance between AB is 2, the Euclidean distance between AC is 3, the distance between AD is 2, the distance between AE is 4, and the distance between AF is 2, then the intra-class neighbors of sample vector A are sample vectors B, D, and F. Similarly, if the intra-class neighbors of sample vectors B and D each include sample vector A, then sample vector A and sample vectors B and D are neighbors to each other, and accordingly, the intra-class neighborhood of sample vector A includes sample vectors B and D.
[0054] At the same time, the sample vectors G, M, N, L have different category labels from A. If the Euclidean distance between AG is 3, the Euclidean distance between AM is 4, the Euclidean distance between AN is 3, and the Euclidean distance between AL is 3, then the sample vectors G, N, and L are the inter-class neighbors of the sample vector A. Similarly, if the inter-class neighbors of the sample vectors G and L include the sample vector A, then the inter-class neighborhood of the sample vector A includes the sample vectors G and L.
[0055] Step 302: Determine the intra-class divergence and inter-class divergence of the feature matrix based on the intra-class neighborhood and inter-class neighborhood of each sample vector.
[0056] In this embodiment, the intra-class divergence is the trace of the intra-class divergence matrix of the feature matrix, and the inter-class divergence is the trace of the inter-class divergence matrix of the feature matrix.
[0057] Usually, the parameter distribution hidden in the modeling motivation of the LDA algorithm assumes that the data distribution of each category is the same Gaussian distribution, and then the covariance matrix of the sample vector is used to characterize the intra-class divergence and inter-class divergence of the data. In the LDA algorithm, the intra-class divergence of the feature matrix is usually determined based on the sum of the squares of the Euclidean distances between each sample vector and all other sample vectors in its category, and the overall divergence of the feature matrix is determined based on the sum of the squares of the Euclidean distances between each sample point and all sample points in the entire feature matrix. The difference between the overall divergence and the inter-class divergence is the inter-class divergence.
[0058] When LDA tries to minimize the intra-class spread, it will minimize all pairs of data belonging to the same class. This assumption is reasonable when the distribution of data in the same class is Gaussian, but when the data in a class consists of multiple clusters, it is not a good idea to force all pairs of samples in the same class to be compressed into a very tight state.
[0059] In this embodiment, the execution entity determines the intra-class divergence of the feature matrix based on the sum of the squares of the Euclidean distances between the sample vector and each sample vector in its intra-class neighborhood, and determines the overall divergence of the feature matrix based on the sum of the squares of the sample vector and the neighboring vectors in the entire feature matrix, wherein the set of neighboring vectors in the entire feature matrix is the union of the intra-class neighborhood and the inter-class neighborhood, and then the difference between the overall divergence and the intra-class divergence is determined as the inter-class divergence of the feature matrix.
[0060] It should be noted that determining the intra-class divergence of the feature matrix based on the sum of squared Euclidean distances between sample vectors is a common method in the LDA algorithm, which will not be described in detail in this disclosure.
[0061] Step 303: Generate a first matrix based on the intra-class divergence and the inter-class divergence.
[0062] In this embodiment, the first matrix represents the difference between the inter-class divergence and the intra-class divergence.
[0063] Step 304: determine the eigenvalue set of the first matrix and the eigenvector corresponding to each eigenvalue.
[0064] In this embodiment, the execution subject may decompose the first matrix into the product sum of eigenvalues and eigenvectors based on the matrix operation rules, and determine the eigenvalue set and the eigenvector corresponding to each eigenvalue.
[0065] Step 305 : construct a projection matrix based on the eigenvectors corresponding to the second preset number of largest eigenvalues in the eigenvalue set.
[0066] As an example, the execution entity may arrange the eigenvalues obtained in step 304 in descending order, and then determine the first second preset number of eigenvalues therefrom, and then use the eigenvectors corresponding to the determined eigenvalues as target vectors to construct a projection matrix.
[0067] The data processing method and device provided by the embodiments of the present disclosure extract features from the acquired data to be processed, and construct a feature matrix based on the extracted features, and then perform dimensionality reduction processing on the feature matrix based on a predetermined projection matrix to obtain a target feature matrix. The projection matrix is determined by the following steps: first, the intra-class neighborhood and inter-class neighborhood of the sample vector are determined, wherein the intra-class neighborhood includes sample vectors that are close neighbors of the sample vector in the same category, and the inter-class neighborhood includes sample vectors that are close neighbors of the sample vector in other categories, and then the intra-class divergence and inter-class divergence of the feature matrix are determined based on the intra-class neighborhood and inter-class neighborhood of each sample vector, so as to determine the projection matrix of the feature matrix. In the dimensionality reduction process, the distance between pairs of sample vectors far away from each other in the same category is avoided, and the distinguishability of the local structure in the data is improved. In particular, when the data of the same category in the data to be processed includes multiple clusters, the compactness of the data of the same category in the target feature matrix is higher, and the distinction between data of different categories is higher.
[0068] Further references Figure 4 , which shows a process 400 of determining a projection matrix in another embodiment of a data processing method. The process 400 of the data processing method includes the following steps:
[0069] Step 401: determine half of the sum of the mean of the sum of the squares of the Euclidean distances between each sample vector in the feature matrix and each sample vector in its intra-class neighborhood as the intra-class divergence.
[0070] As an example, the execution subject may determine the intra-class divergence of the feature matrix through formula (1).
[0071]
[0072] In the formula, represents the intra-class dispersion matrix of the feature matrix, represents the intra-class divergence of the feature matrix, i∈(0,1,2,…,c) represents the category label, X i represents the set of sample vectors of the i-th category in the feature matrix, x j ∈X i represents the jth sample vector in the i-th category, k w (j) represents x j The intra-class neighborhood The number of sample vectors in , Represents x j∈X i The nearest neighbor vector within the class.
[0073] Step 402: determine half of the sum of the mean of the sum of the squares of the Euclidean distances between each sample vector in the feature matrix and each sample vector in the first neighborhood as the overall divergence of the feature matrix.
[0074] In this embodiment, the first neighborhood is the union of the intra-class neighborhood and the inter-class neighborhood, and the first neighborhood of each sample vector includes the nearest neighbor vectors of the sample vector in all sample vectors of the feature matrix.
[0075] In conjunction with the example in step 401, the execution entity can determine the total graph divergence of the feature matrix by using formula (2).
[0076]
[0077] In the formula, represents the overall scatter matrix of the feature matrix, represents the overall divergence of the feature matrix, k b (j) represents x j The inter-class neighborhood The number of sample vectors in , in, Represents x j The first neighbor of .
[0078] Step 403: determine the difference between the overall divergence and the intra-class divergence as the inter-class divergence.
[0079] Continuing with the above example, the execution subject can use formula (3) to determine the inter-class divergence of the feature matrix.
[0080]
[0081] In the formula, represents the inter-class scatter matrix of the feature matrix, Represents the between-class divergence of the feature matrix.
[0082] Step 404: determine a matrix obtained by multiplying the intra-class divergence by the preset weight as a second matrix.
[0083] Step 405: determine the difference between the inter-class divergence and the second matrix as the first matrix.
[0084] Step 406: Determine the eigenvalue set of the first matrix and the eigenvector corresponding to each eigenvalue.
[0085] In this embodiment, the preset weight is the ratio of the inter-class divergence to the intra-class divergence, which is used to determine the balance point between the intra-class divergence and the inter-class divergence. The first matrix is used to determine the target vector in the projection matrix.
[0086] In the LDA algorithm, the intra-class divergence is negatively correlated with the compactness of the data of the same category in the target feature matrix. The smaller the absolute value of the intra-class divergence, the higher the data compactness. At the same time, the discrimination of data between different categories in the target feature matrix is negatively correlated with the inter-class divergence. The larger the absolute value of the inter-class divergence, the higher the data discrimination. Therefore, the balance point between the inter-class divergence and the intra-class divergence is related to the accuracy of the target feature matrix for the data features.
[0087] In the related art, each target vector in the projection matrix is usually determined directly based on the difference between the inter-class divergence and the intra-class divergence. This method has errors in representing the data divergence. Therefore, this embodiment uses the preset weight of the intra-class divergence and the first matrix to determine each target vector in the projection matrix to determine the optimal projection direction, thereby improving the accuracy of the target feature matrix in describing the data divergence.
[0088] Step 407: construct a projection matrix based on the eigenvectors corresponding to the second preset number of largest eigenvalues in the eigenvalue set. This step corresponds to the aforementioned step 305 and will not be described in detail here.
[0089] from Figure 4 It can be seen that the process 400 for determining the projection matrix in this embodiment highlights the solution process of optimizing the projection matrix using preset weights, thereby improving the accuracy of the target feature matrix in describing the data divergence.
[0090] exist Figure 4 In some optional implementations of the illustrated embodiment, the second preset number may be determined in the following manner: determining the number of eigenvalues in the eigenvalue set that are greater than 0; and determining the number as the second preset number.
[0091] In the usual data dimensionality reduction process, the dimension of the target feature matrix can be pre-set according to the needs. There is no correlation between the dimension of the target feature matrix obtained in this way and the characteristics of the data to be processed itself. For example, the target vector may include eigenvectors corresponding to eigenvalues less than 0. The projection direction represented by this target vector will affect the accuracy of the target feature matrix in representing the data characteristics.
[0092] In this implementation, the execution subject can determine the optimal dimension of the target feature matrix based on the characteristics of the data to be processed, thereby further improving the correlation between the target feature matrix and the data to be processed, so that the target feature matrix can more accurately characterize the characteristics of the data.
[0093] exist Figure 2 and Figure 4 In the illustrated embodiment, the data processing method of the present disclosure further includes: ignoring the null space of the overall divergence.
[0094] Since the null space in the overall scatter matrix cannot provide any discriminative information, the null space of the overall scatter can be ignored during the calculation process, which helps to reduce the dimension of the data and improve the calculation efficiency.
[0095] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a data processing device, and the device embodiment is Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0096] like Figure 5 As shown, the data processing device 500 of this embodiment includes: a data acquisition unit 501, configured to acquire data to be processed; a feature extraction unit 502, configured to extract features of the data, and construct a feature matrix based on the extracted features, the feature matrix including a first preset number of sample vectors pre-marked with category labels; a feature dimension reduction unit 503, configured to generate a target feature matrix based on the feature matrix and a predetermined projection matrix, the target feature matrix including a second preset number of target vectors, the second preset number is less than the first preset number, and the target vector is a projection vector obtained by the sample vector based on the projection matrix; wherein the projection matrix is determined by the projection determination unit 504 performing the following steps: determining The intra-class neighborhood and inter-class neighborhood of each sample vector, wherein the intra-class neighborhood includes sample vectors that are neighbors of the sample vector in the category to which the sample vector belongs, and the inter-class neighborhood includes sample vectors that are neighbors of the sample vector in other categories; based on the intra-class neighborhood and inter-class neighborhood of each sample vector, the intra-class divergence and inter-class divergence of the feature matrix are determined, the intra-class divergence is the trace of the intra-class divergence matrix of the feature matrix, and the inter-class divergence is the trace of the inter-class divergence matrix of the feature matrix; based on the intra-class divergence and inter-class divergence, a first matrix is generated; the eigenvalue set of the first matrix and the eigenvector corresponding to each eigenvalue are determined; based on the eigenvectors corresponding to the largest second preset number of eigenvalues in the eigenvalue set, a projection matrix is constructed.
[0097] In some embodiments, the projection determination unit 504 further includes: an intra-class divergence determination module, configured to determine half of the sum of the mean of the sum of the squares of the Euclidean distances between each sample vector in the feature matrix and each sample vector in its intra-class neighborhood as the intra-class divergence; an overall divergence determination module, configured to determine half of the sum of the mean of the sum of the squares of the Euclidean distances between each sample vector in the feature matrix and each sample vector in the first neighborhood as the overall divergence of the feature matrix, where the first neighborhood is the union of the intra-class domain and the inter-class neighborhood; and an inter-class divergence determination unit, configured to determine the difference between the overall divergence and the intra-class divergence as the inter-class divergence.
[0098] In some embodiments, the projection determination unit 504 also includes a matrix generation module, which is configured to: determine a matrix obtained by multiplying the intra-class divergence and a preset weight as a second matrix; determine the difference between the inter-class divergence and the second matrix as a first matrix; wherein the preset weight is the ratio of the inter-class divergence to the intra-class divergence.
[0099] In some embodiments, the device 500 further includes a quantity determination unit 505 configured to: determine the number of feature values greater than 0 in the feature value set; and determine the number as a second preset number.
[0100] In some embodiments, the projection determination unit 504 is further configured to ignore the null space of the overall divergence.
[0101] Reference below Figure 6 , which shows an electronic device (eg, Figure 1 The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The terminal device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0102] like Figure 6 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0103] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 6 Each block shown in the figure may represent one device, or may represent multiple devices as required.
[0104] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above functions defined in the method of the embodiment of the present disclosure are executed. It should be noted that the computer-readable medium described in the embodiment of the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In an embodiment of the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, an apparatus, or a device. In an embodiment of the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction execution system, an apparatus, or a device. The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wire, optical cable, RF (radio frequency), etc., or any suitable combination of the foregoing.
[0105] The above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist independently without being assembled into the electronic device. The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains the data to be processed; extracts the features of the data, and constructs a feature matrix based on the extracted features, the feature matrix includes a first preset number of sample vectors pre-marked with category labels; based on the feature matrix and a predetermined projection matrix, generates a target feature matrix, the target feature matrix includes a second preset number of target vectors, the second preset number is less than the first preset number, and the target vector is the projection vector obtained by the sample vector based on the projection matrix; wherein the projection matrix is determined by the following steps: determining the intra-class neighborhood and the projection matrix of each sample vector Inter-class neighborhood, wherein the intra-class neighborhood includes sample vectors that are neighbors of the sample vector in the category to which the sample vector belongs, and the inter-class neighborhood includes sample vectors that are neighbors of the sample vector in other categories; based on the intra-class neighborhood and inter-class neighborhood of each sample vector, the intra-class divergence and inter-class divergence of the feature matrix are determined, the intra-class divergence is the trace of the intra-class divergence matrix of the feature matrix, and the inter-class divergence is the trace of the inter-class divergence matrix of the feature matrix; based on the intra-class divergence and inter-class divergence, a first matrix is generated; the eigenvalue set of the first matrix and the eigenvector corresponding to each eigenvalue are determined; based on the eigenvectors corresponding to the largest second preset number of eigenvalues in the eigenvalue set, a projection matrix is constructed.
[0106] Computer program code for performing the operations of embodiments of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as a separate software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0107] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0108] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The units described may also be provided in a processor, for example, may be described as: a processor including a data acquisition unit, a feature extraction unit, and a feature dimension reduction unit. The names of these units do not, in some cases, constitute limitations on the units themselves, for example, the data acquisition unit may also be described as a "unit for acquiring data to be processed".
[0109] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by a specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalent features without departing from the above-mentioned inventive concept. For example, the above-mentioned features are replaced with the technical features with similar functions disclosed in the embodiments of the present disclosure (but not limited to) to form a technical solution.
Claims
1. A method for data processing, wherein: include: Acquire data to be processed, wherein the data is image data or text data; Extracting features of the data, and constructing a feature matrix based on the extracted features, wherein the feature matrix includes a first preset number of sample vectors pre-labeled with category labels; Based on the feature matrix and a predetermined projection matrix, a target feature matrix is generated, wherein the target feature matrix includes a second preset number of target vectors, the second preset number is smaller than the first preset number, and the target vector is a projection vector of the sample vector obtained based on the projection matrix; The projection matrix is determined by the following steps: Determine the intra-class neighborhood and inter-class neighborhood of each sample vector, wherein the intra-class neighborhood includes sample vectors that are neighbors of the sample vector in the category to which the sample vector belongs, and the inter-class neighborhood includes sample vectors that are neighbors of the sample vector in other categories; based on the intra-class neighborhood and inter-class neighborhood of each sample vector, determine the intra-class divergence and inter-class divergence of the feature matrix, wherein the intra-class divergence is the trace of the intra-class divergence matrix of the feature matrix, and the inter-class divergence is the trace of the inter-class divergence matrix of the feature matrix; based on the intra-class divergence and the inter-class divergence, generate a first matrix, wherein the first matrix is used to characterize the difference between the inter-class divergence and the intra-class divergence; determine the eigenvalue set of the first matrix and the eigenvector corresponding to each eigenvalue; and construct the projection matrix based on the eigenvectors corresponding to the largest second preset number of eigenvalues in the eigenvalue set.
2. The method according to claim 1, wherein: Based on the intra-class neighborhood and inter-class neighborhood of each sample vector, the intra-class divergence and inter-class divergence of the feature matrix are determined, including: Determine half of the sum of the squares of the Euclidean distances between each sample vector in the feature matrix and each sample vector in its intra-class neighborhood as the intra-class divergence; Determine half of the sum of the mean of the sum of the squares of the Euclidean distances between each sample vector in the feature matrix and each sample vector in a first neighborhood as the overall divergence of the feature matrix, wherein the first neighborhood is the union of the intra-class domain and the inter-class neighborhood; The difference between the overall divergence and the intra-class divergence is determined as the inter-class divergence.
3. The method according to claim 2, wherein: The first matrix is generated by the following steps: Determine a matrix obtained by multiplying the intra-class divergence by a preset weight as a second matrix; Determine the difference between the inter-class divergence and the second matrix as the first matrix; The preset weight is the ratio of the inter-class divergence to the intra-class divergence.
4. The method according to claim 3, wherein: The second preset number is determined by the following steps: Determining the number of eigenvalues greater than 0 in the eigenvalue set; The number is determined as the second preset number. 5 . The method according to claim 2 , further comprising ignoring the null space of the overall divergence.
6. A data processing device, wherein: include: A data acquisition unit, configured to acquire data to be processed, wherein the data is image data or text data; A feature extraction unit is configured to extract features of the data and construct a feature matrix based on the extracted features, wherein the feature matrix includes a first preset number of sample vectors pre-labeled with category labels; a feature dimension reduction unit, configured to generate a target feature matrix based on the feature matrix and a predetermined projection matrix, wherein the target feature matrix includes a second preset number of target vectors, the second preset number is smaller than the first preset number, and the target vector is a projection vector of the sample vector based on the projection matrix; The projection matrix is determined by the projection determination unit performing the following steps: Determine an intra-class neighborhood and an inter-class neighborhood of each sample vector, wherein the intra-class neighborhood includes sample vectors in the category to which the sample vector belongs that are close neighbors to the sample vector, and the inter-class neighborhood includes sample vectors in other categories that are close neighbors to the sample vector; Based on the intra-class neighborhood and inter-class neighborhood of each sample vector, determine the intra-class divergence and inter-class divergence of the feature matrix, wherein the intra-class divergence is the trace of the intra-class divergence matrix of the feature matrix, and the inter-class divergence is the trace of the inter-class divergence matrix of the feature matrix; Based on the intra-class divergence and the inter-class divergence, a first matrix is generated, wherein the first matrix is used to represent the difference between the inter-class divergence and the intra-class divergence; Determine a set of eigenvalues of the first matrix and an eigenvector corresponding to each eigenvalue; The projection matrix is constructed based on eigenvectors corresponding to a second preset number of largest eigenvalues in the eigenvalue set.
7. The device according to claim 6, wherein: The projection determination unit further comprises: an intra-class dispersion determination module configured to determine half of the sum of the squares of the Euclidean distances between each sample vector in the feature matrix and each sample vector in its intra-class neighborhood as the intra-class dispersion; a total divergence determination module configured to determine half of the sum of the squares of the mean of the Euclidean distances between each sample vector in the feature matrix and each sample vector in a first neighborhood as the total divergence of the feature matrix, wherein the first neighborhood is a union of the intra-class domain and the inter-class neighborhood; The inter-class divergence determination unit is configured to determine a difference between the overall divergence and the intra-class divergence as the inter-class divergence.
8. The device according to claim 7, wherein: The projection determination unit further includes a matrix generation module configured to: Determine a matrix obtained by multiplying the intra-class divergence by a preset weight as a second matrix; Determine the difference between the inter-class divergence and the second matrix as the first matrix; The preset weight is the ratio of the inter-class divergence to the intra-class divergence.
9. The device according to claim 8, wherein: The device further comprises a quantity determination unit configured to: Determining the number of eigenvalues greater than 0 in the eigenvalue set; The number is determined as the second preset number. 10 . The apparatus according to claim 7 , wherein the projection determination unit is further configured to ignore a null space of the overall divergence.
11. An electronic device, comprising: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.
12. A computer readable medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Method and device for obtaining projection transformation matrix and sample classification method and device
CN103886345A
Sample identification method and device
CN112308097A