Data classification method, apparatus, device, and storage medium
By constructing an optimization function and iteratively updating the dimensional correlation matrix, the problem of inaccurate measurement of similarity of Euclidean distance in high-dimensional data points is solved, and more accurate data classification is achieved.
Patent Information
- Application Number
- CN202110336040.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-29
- Publication Date
- 2026-01-20
- Estimated Expiration
- 2041-03-29
AI Technical Summary
Existing Euclidean distance methods are inaccurate in measuring the similarity between high-dimensional data points, leading to inaccurate data classification.
By obtaining the covariance matrices of sample pairs of the same and different categories, an optimization function is constructed to iteratively update the dimensional correlation matrix, so as to classify the data based on the optimized dimensional correlation matrix.
It improves the accuracy of data classification, especially by using class-specific and class-dissimilar constraints to classify data without relying on specific category labels.
Smart Images

Figure CN114118179B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of machine learning, and in particular, to a data classification method and device, equipment and readable storage medium. BACKGROUND
[0002] Distance metric is a key problem in many machine learning algorithms. For example, in K-means clustering algorithm, clustering needs to be performed according to the similarity of data points in the feature space, and the similarity of data points in the feature space can be determined by distance metric, so it is necessary to provide a suitable distance metric for the algorithm. The commonly used distance metric is Euclidean distance, also known as Euclidean distance. When calculating the Euclidean distance between data points, it is assumed that each feature of the data point is equally important and independent of each other. However, in actual applications, the assumption of Euclidean distance may not conform to the true situation of the data. For example, when processing high-dimensional data in which some features may not be closely related to the target of interest, if the Euclidean distance between data points is used to measure the similarity between them, the result obtained is inaccurate, which further leads to inaccurate classification of data.
[0003] As described above, how to provide a distance obtaining method for more accurately measuring the similarity between data points has become a problem to be solved.
[0004] The above information disclosed in the background section is only intended to strengthen the understanding of the background of the present disclosure, and therefore it can include information that does not constitute the prior art known to those of ordinary skill in the art. SUMMARY
[0005] The purpose of the present disclosure is to provide a data classification method and device, equipment and readable storage medium, which at least partially overcome the problem that the data classification result obtained by using the Euclidean distance between data points to measure the similarity between them is inaccurate.
[0006] Other characteristics and advantages of the present disclosure will become apparent from the following detailed description, or will be learned by practice of the present disclosure.
[0007] According to an aspect of the present disclosure, a data classification method is provided, including: obtaining sample pairs of the same category and sample pairs of different categories; obtaining a covariance matrix of the sample pairs of the same category and a covariance matrix of the sample pairs of different categories respectively; obtaining an optimization function according to the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories, a variable of the optimization function including a dimension correlation matrix and a ratio of a dimension correlation distance sum of squares of the sample pairs of different categories to the sample pairs of the same category; iteratively updating the initial dimension correlation matrix by the optimization function in a direction of a larger dimension correlation distance sum of squares, to obtain an optimized dimension correlation matrix, so as to classify data to be classified based on the optimized dimension correlation matrix.
[0008] According to an embodiment of the present disclosure, the iteratively updating the initial dimension correlation matrix by the optimization function in a direction of a larger dimension correlation distance sum of squares includes: obtaining an iterative formula according to the optimization function, the iterative formula being used to represent an operation relationship between the dimension correlation distance sum of squares and the dimension correlation matrix, the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories; obtaining an initial dimension correlation distance sum of squares based on the optimization function according to the initial dimension correlation matrix; taking the initial dimension correlation matrix and the initial dimension correlation distance sum of squares as a current dimension correlation matrix and a current dimension correlation distance sum of squares respectively; obtaining a next dimension correlation matrix according to the current dimension correlation matrix, the covariance matrix of the sample pairs of the same category, the covariance matrix of the sample pairs of different categories and the current dimension correlation distance sum of squares; substituting the next dimension correlation matrix into the iterative formula to obtain a next dimension correlation distance sum of squares; taking the next dimension correlation matrix and the next dimension correlation distance sum of squares as the current dimension correlation matrix and the current dimension correlation distance sum of squares respectively, and iteratively performing the step of obtaining a next dimension correlation matrix and the step of obtaining a next dimension correlation distance sum of squares until convergence.
[0009] According to an embodiment of the present disclosure, the obtaining the next dimension correlation matrix according to the current dimension correlation matrix, the covariance matrix of the sample pairs of the same category, the covariance matrix of the sample pairs of different categories and the current dimension correlation distance sum ratio comprises: multiplying the transpose of the current dimension correlation matrix, the difference between the product of the covariance matrix of the sample pairs of different categories and the current dimension correlation distance sum ratio and the covariance matrix of the sample pairs of the same category, and the current dimension correlation matrix in turn to obtain an optimization square matrix; performing eigenvalue decomposition on the optimization square matrix to obtain the next dimension correlation matrix.
[0010] According to an embodiment of the present disclosure, the performing eigenvalue decomposition on the optimization square matrix to obtain the next dimension correlation matrix comprises: performing eigenvalue decomposition on the optimization square matrix to obtain a plurality of eigenvectors; and arranging the plurality of eigenvectors according to the dimension of the current dimension correlation matrix to obtain the next dimension correlation matrix.
[0011] According to an embodiment of the present disclosure, the obtaining the initial dimension correlation distance sum ratio based on the optimization function and the initial dimension correlation matrix comprises: substituting the initial dimension correlation matrix into the optimization function to obtain the initial dimension correlation distance sum ratio.
[0012] According to an embodiment of the present disclosure, the dimension correlation distance sum of the sample pairs is the trace of a dimension correlation distance square matrix, wherein the dimension correlation distance square matrix is obtained by multiplying the transpose of a dimension correlation matrix, the covariance matrix of the sample pairs and the dimension correlation matrix in turn.
[0013] According to an embodiment of the present disclosure, the obtaining the optimization function according to the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories comprises: establishing a proportional relationship between the dimension correlation distance sum of the sample pairs of different categories and the dimension correlation distance sum of the sample pairs of the same category by using the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories to obtain the optimization function.
[0014] According to still another aspect of the present disclosure, there is provided a data classification apparatus, comprising: a constraint set obtaining module configured to obtain sample pairs of the same category and sample pairs of different categories; a covariance matrix obtaining module configured to obtain a covariance matrix of the sample pairs of the same category and a covariance matrix of the sample pairs of different categories respectively; an optimization function obtaining module configured to obtain an optimization function according to the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories, wherein a variable of the optimization function comprises a dimension correlation matrix and a ratio of a dimension correlation distance sum of squares of the sample pairs of different categories to the sample pairs of the same category; and a dimension correlation matrix obtaining module configured to obtain an optimized dimension correlation matrix by iteratively updating the initial dimension correlation matrix towards a direction of a larger dimension correlation distance sum of squares ratio according to the optimization function, so as to classify data to be classified based on the optimized dimension correlation matrix.
[0015] According to an embodiment of the present disclosure, the dimension correlation matrix obtaining module comprises: an iterative obtaining module configured to obtain an iteration formula according to the optimization function, wherein the iteration formula is used to represent an operation relationship between the dimension correlation distance sum of squares ratio and the dimension correlation matrix, the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories; an initial ratio obtaining module configured to obtain an initial dimension correlation distance sum of squares ratio based on the optimization function according to the initial dimension correlation matrix; a current value obtaining module configured to take the initial dimension correlation matrix and the initial dimension correlation distance sum of squares ratio as a current dimension correlation matrix and a current dimension correlation distance sum of squares ratio respectively; a first iteration module configured to obtain a next dimension correlation matrix according to the current dimension correlation matrix, the covariance matrix of the sample pairs of the same category, the covariance matrix of the sample pairs of different categories and the current dimension correlation distance sum of squares ratio; a second iteration module configured to take the next dimension correlation matrix into the iteration formula to obtain a next dimension correlation distance sum of squares ratio; and an iteration constraint module configured to take the next dimension correlation matrix and the next dimension correlation distance sum of squares ratio as the current dimension correlation matrix and the current dimension correlation distance sum of squares ratio respectively, and iteratively execute the step of obtaining a next dimension correlation matrix by the first iteration module and the step of obtaining a next dimension correlation distance sum of squares ratio by the second iteration module until convergence.
[0016] According to an embodiment of the present disclosure, the first iteration module comprises: an optimization matrix calculation module, configured to multiply the transpose of the current dimension correlation matrix, the difference between the product of the covariance matrix of the sample pairs of different categories and the current dimension correlation distance square sum ratio and the covariance matrix of the sample pairs of the same category, and the current dimension correlation matrix in sequence, to obtain an optimization matrix; and a dimension correlation matrix calculation module, configured to perform eigenvalue decomposition on the optimization matrix to obtain the next dimension correlation matrix.
[0017] According to an embodiment of the present disclosure, the dimension correlation matrix calculation module comprises: an eigenvalue decomposition module, configured to perform eigenvalue decomposition on the optimization matrix to obtain a plurality of eigenvectors; and a dimension correlation matrix obtaining module, configured to arrange the plurality of eigenvectors according to the dimension of the current dimension correlation matrix to obtain the next dimension correlation matrix.
[0018] According to an embodiment of the present disclosure, the initial ratio obtaining module is further configured to substitute the initial dimension correlation matrix into the optimization function to obtain the initial dimension correlation distance square sum ratio.
[0019] According to an embodiment of the present disclosure, the dimension correlation distance square sum of the sample pairs is the trace of a dimension correlation distance square matrix, wherein the dimension correlation distance square matrix is obtained by multiplying the transpose of the dimension correlation matrix, the covariance matrix of the sample pairs, and the dimension correlation matrix in sequence.
[0020] According to an embodiment of the present disclosure, the optimization function obtaining module is further configured to establish a proportional relationship between the dimension correlation distance square sum of the sample pairs of different categories and the dimension correlation distance square sum of the sample pairs of the same category by using the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories, to obtain the optimization function.
[0021] According to still another aspect of the present disclosure, there is provided a device comprising a memory, a processor, and executable instructions stored in the memory and executable in the processor, wherein the processor executes the executable instructions to implement any of the above methods.
[0022] According to still another aspect of the present disclosure, there is provided a computer readable storage medium having stored thereon computer executable instructions, wherein the executable instructions are executed by a processor to implement any of the above methods.
[0023] The data classification method provided in the embodiments of this disclosure obtains an optimization function based on the covariance matrices of sample pairs of the same category and sample pairs of different categories. The optimization function is used to obtain an optimization function with the dimensional correlation matrix and the ratio of the sum of squared dimensional correlation distances between sample pairs of different categories and sample pairs of the same category as variables. Then, the initial dimensional correlation matrix is iteratively updated by the optimization function in the direction of increasing the ratio of the sum of squared dimensional correlation distances to obtain an optimized dimensional correlation matrix. The data to be classified is then classified based on the optimized dimensional correlation matrix. This enables the classification of data by measuring the similarity of data based on dimensional correlation distance, thereby improving the accuracy of data classification.
[0024] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this disclosure. Attached Figure Description
[0025] The above and other objects, features and advantages of this disclosure will become more apparent from a detailed description of exemplary embodiments thereof with reference to the accompanying drawings.
[0026] Figure 1 A schematic diagram of a system structure according to an embodiment of this disclosure is shown.
[0027] Figure 2 A flowchart of a data classification method according to an embodiment of this disclosure is shown.
[0028] Figure 3 It shows Figure 2 The step S208 shown is a schematic diagram of the processing procedure in one embodiment.
[0029] Figure 4 A schematic diagram of an iterative algorithm flow is shown in an embodiment of this disclosure.
[0030] Figure 5 A block diagram of a data classification apparatus according to an embodiment of the present disclosure is shown.
[0031] Figure 6 A block diagram of another data classification apparatus according to an embodiment of this disclosure is shown.
[0032] Figure 7 A schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation
[0033] Example embodiments now will be described more fully hereinafter with reference to the accompanying drawings; however, the example embodiments can be implemented in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the example embodiments to those skilled in the art. The accompanying drawings are included to provide a further understanding of the disclosure and are incorporated into and constitute a part of this disclosure. The drawings are not intended to be restrictive in any way. Throughout the drawings, like references numerals denote like features.
[0034] In addition, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the techniques described herein can be practiced without one or more of the specific details, or with other methods, components, materials, and so forth. In other instances, well-known structures, materials, or operations are not shown or described in detail in order to avoid obscuring aspects of the disclosure.
[0035] In addition, the terms "first", "second", and the like, do not denote any order, quantity, combination, or importance, but rather are used to nomenclature different components. Thus, a "first" and / or "second" feature can include one or more of the feature, either explicitly or implicitly. In the description of the disclosure, the meaning of "a plurality" is at least two, such as two, three, etc., unless otherwise specifically defined. The symbol " / " generally represents an "or" relationship between the objects before and after the symbol.
[0036] In the present disclosure, unless otherwise explicitly specified and limited, the term "connected" and the like should be interpreted broadly, for example, can be electrically connected or can communicate with each other; can be directly connected, or can be indirectly connected through an intermediate medium. For those skilled in the art, the specific meaning of the above-mentioned terms in the present disclosure can be understood according to the specific circumstances.
[0037] The choice of distance metric is closely related to the target problem to be solved, and even relates to the success or failure of the learning algorithm or the developed system. As described above, when measuring the similarity of high-dimensional data in which some features may not be closely related to the target of interest, the Euclidean distance method does not conform to the true situation of the data. Contrary to the assumption of Euclidean distance, a more realistic distance metric method should be able to identify important features and distinguish between relevant and irrelevant features.
[0038] In the related art, distance metric learning is learned based on labeled training data samples, such as neighborhood component analysis, large margin nearest neighbor classification, large margin principal component analysis, and other extensions. The successful application of the above algorithms in different problems shows that the learned distance metric has substantial improvement compared to the commonly used Euclidean distance metric. However, the data used for learning in these algorithms needs to have class labels, and the class labels can be important information from the user, which is not easy to obtain in some practical situations.
[0039] Therefore, the present disclosure provides a data classification method, which obtains an optimization function with a dimension correlation matrix and a ratio of a dimension correlation distance square sum of different class sample pairs to that of same class sample pairs as variables according to the covariance matrix of same class sample pairs and the covariance matrix of different class sample pairs, then iteratively updates the initial dimension correlation matrix in the direction of a larger ratio of dimension correlation distance square sum by the optimization function, and obtains an optimized dimension correlation matrix, so as to classify the data to be classified based on the optimized dimension correlation matrix, thereby realizing the classification of data by using the similarity of data measured by the dimension correlation distance optimized by the same class and different class constrained data without the need of data with specific class labels, and improving the accuracy of data classification.
[0040] Figure 1 An exemplary system architecture 10 to which the data classification method or data classification apparatus of the present disclosure can be applied is shown.
[0041] As shown in Figure 1 The system architecture 10 can include a terminal device 102, a network 104, a server 106, and a database 108. The terminal device 102 can be various electronic devices with a display screen and supporting input and output, including but not limited to a smartphone, a tablet computer, a laptop computer, a desktop computer, a wearable device, a virtual reality device, a smart home, and the like. The network 104 is a medium to provide a communication link between the terminal device 102 and the server 106. The network 104 can include various connection types, such as wired, wireless communication links, or optical fiber cables, and the like. The server 106 can be a server or a cluster of servers, etc. that provides various services. The database 108 can be a large database software placed on a server, or a small database software installed on a computer, used for storing data.
[0042] The user can use the terminal device 102 to interact with the server 106 and the database 108 through the network 104 to receive or send data, etc. For example, the user uses the terminal device 102 to input the iteration parameters, and then uploads the iteration parameters to the server 106 through the network 104 for iteration calculation of the dimension correlation matrix, and then the server 106 classifies the to-be-classified data by using the dimension correlation matrix, and transmits the data classification result to the terminal device 102 through the network 104.
[0043] The server 106 can also receive data from the database 108 or send data to the database 108 through the network 104, etc. For example, the server 106 can be a background processing server, which obtains the same-class sample data and different-class sample data from the database 108 through the network 104, iteratively calculates the dimension correlation matrix, and stores the process result in the iteration step into the database 108 through the network 104.
[0044] It should be understood that Figure 1 The number of terminal devices, networks, servers and databases in the system is only illustrative. According to the needs of implementation, there can be any number of terminal devices, networks and servers.
[0045] Figure 2 is a flowchart of a data classification method according to an exemplary embodiment. As Figure 2 The method shown in the figure can be applied to the server side of the system described above, and can also be applied to the terminal device of the system described above.
[0046] Referring to Figure 2 The method 20 provided by the embodiment of the disclosure can include the following steps.
[0047] In step S202, a same-class sample pair and a different-class sample pair are obtained. Such pair constraints of the same class (similar) or different class (dissimilar) of the sample pair exist in many application scenarios. For example, in image retrieval, similar image pairs and dissimilar image pairs can be obtained by marking the images similar and dissimilar to the query results by the user. Compared with mining a suitable distance metric by using sample class labels, the connected constraint (same class) and the disconnected constraint (different class) information of the sample pair is more easily obtained, and the distance metric can be more naturally learned by using the prior information strategy of the data itself.
[0048] In step S204, a covariance matrix of the same-class sample pair and a covariance matrix of the different-class sample pair are obtained, respectively. The sample data can have multiple attributes, and each sample can include features of multiple dimensions, that is, each sample can be represented by a multi-dimensional random variable, and the covariance matrix of the sample set can be used to represent the relationship between the multiple dimensions of the sample set.
[0049] In some embodiments, a sample set is represented as where i, N, n are all positive integers, i≤N, there are two sets of pair constraints: a connected set and x sj belong to the same category}, si, sj≤N, a non-connected set and x bj belong to different categories}, bi, bj≤N. The connected set can be represented as follows: s
[0050]
[0051] wherein The non-connected set can be represented as follows: b
[0052]
[0053] wherein
[0054] In step S206, an optimization function is obtained according to the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories, and the variables of the optimization function include the dimension correlation matrix and the ratio of the sum of squares of the dimension correlation distances of the sample pairs of different categories to the sum of squares of the dimension correlation distances of the sample pairs of the same category. The proportional relationship between the sum of squares of the dimension correlation distances of the sample pairs of different categories and the sum of squares of the dimension correlation distances of the sample pairs of the same category can be established by using the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories, and an optimization function for obtaining an optimized dimension correlation matrix is established, which can be used to calculate the dimension correlation distance between sample points, and the dimension correlation distance between sample points can be used to measure the similarity between sample points.
[0055] In some embodiments, for example, given two sample points and their dimension correlation distance d A (x1, x2) can be calculated as follows:
[0056]
[0057] wherein is a positive semi-definite matrix, and according to the properties of the positive semi-definite matrix, the matrix A can be decomposed as A = WW T , and the matrix W is the above-mentioned dimension correlation matrix, Where d ≤ n, when d < n, matrix W is not a square matrix; when the two are unequal, there is redundancy in the sample data (in which case W is not a square matrix and data compression can be performed). T This will not be equal to the identity matrix; while when d = n, we have WW T =W T When W = I (unit vector), there is no data loss after projecting the data using W, and the dimensionality correlation distance between the samples is equal to the Euclidean distance. Therefore, the dimensionality correlation distance between two sample points can be expressed as:
[0058]
[0059] According to equation (4), the necessarily connected set can be... Dimensional correlation distance sum d of sample pairs s Represented as:
[0060]
[0061] Here, tr represents the matrix trace operator, which can be introduced by the linear transformation y = W. T x is derived. Similarly, disjoint sets... The dimensionality correlation of sample pairs and the sum of squared distances d b It can be represented as:
[0062]
[0063] The following optimization objective formula can be constructed based on equations (5) and (6):
[0064]
[0065] Among them, W * To maximize the ratio W, the optimization objective of equation (7) above is to optimize W = W. * This makes disjoint sets The dimensionality correlation of sample pairs and the sum of squared distances d b Make the set as large as possible so that it is necessarily connected. Dimensional correlation distance sum d of sample pairs s Make d as small as possible. b / d s (i.e., the ratio of the sum of squared distances of dimensional correlation between sample pairs of different categories and sample pairs of the same category) is denoted as λ, assuming that when W = W * When optimizing the objective formula (7)d b / d s Reaching the global maximum value λ * :
[0066]
[0067] Obviously, for any W, d b / d s is always less than or equal to λ * :
[0068]
[0069] By formula (9), we have:
[0070]
[0071] According to formula (10), a function f1(λ) = max tr(W T (C b -λC s )W) is constructed with λ as the independent variable, and f1(λ * ) = 0 if and only if λ = λ * , where f1(λ) can be rewritten as where w i is an n-length row vector of the matrix W. Now, an optimization function f2(λ m ) for iterative optimization of the dimension correlation matrix is constructed according to the function f1(λ), where m is the number of iterations, and m is a positive integer greater than or equal to 1. Assuming that λ m = λ * , we have:
[0072]
[0073] In the function f1(λ), W is not fixed, and the function f2(λ m ) can be defined as:
[0074]
[0075] The function f2(λ m ) is the optimization function obtained for iteration.
[0076] In step S208, the initial dimension correlation matrix is iteratively updated in the direction of a larger dimension correlation distance square sum ratio value by the optimization function, and an optimized dimension correlation matrix is obtained. The classification of the data to be classified is performed based on the optimized dimension correlation matrix. The initial dimension correlation matrix can be iteratively updated in the direction of a larger dimension correlation distance square sum ratio value by an optimization function with the dimension correlation matrix and the dimension correlation distance square sum ratio value of different class sample pairs and same class sample pairs as variables, and an optimized dimension correlation matrix that maximizes the dimension correlation distance square sum ratio value is obtained.
[0077] In some embodiments, for example, an iterative formula for representing the ratio of the sum of squares of the dimension correlation distance with the dimension correlation matrix can be obtained according to the optimization function, and then the iterative formula is used for iteration. For a detailed description, reference can be made to Figure 3 and Figure 4 .
[0078] In some embodiments, the dimension correlation matrix W is obtained by iteration. * After that, the dimension correlation distance matrix A used for calculating the dimension correlation distance can be obtained in the following manner:
[0079]
[0080] The dimension correlation distance matrix A makes the distance between the sample pairs in the connected set as small as possible, and the distance between the sample pairs in the unconnected set as large as possible.
[0081] According to the data classification method provided by the embodiments of the present disclosure, the optimization function with the dimension correlation matrix and the ratio of the sum of squares of the dimension correlation distance between the sample pairs of different categories and the sample pairs of the same category as variables is obtained according to the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories, then the initial dimension correlation matrix is updated in the direction of a larger ratio of the sum of squares of the dimension correlation distance by the optimization function, and the optimized dimension correlation matrix is obtained, so that the data to be classified is classified based on the optimized dimension correlation matrix, thereby embedding more data priori knowledge into the algorithm by using auxiliary information such as the connected constraint and the unconnected constraint information of the sample pairs, avoiding the use of label information which needs to be obtained at a high cost, realizing the classification of data according to the similarity of the dimension correlation distance, improving the accuracy of data classification, and overcoming the problem that the related distance metric learning method depends heavily on the sample label.
[0082] Figure 3 A schematic diagram of the processing process of step S208 shown in Figure 2 in an embodiment is shown. As shown in Figure 3 , in the embodiments of the present disclosure, the above step S208 can further include the following steps.
[0083] Step S2082, an iterative formula is obtained according to the optimization function, and the iterative formula is used to represent the operation relationship between the ratio of the sum of squares of the dimension correlation distance and the dimension correlation matrix, the covariance matrix of the sample pairs of the same category, and the covariance matrix of the sample pairs of different categories.
[0084] In some embodiments, the slope of the function f(λ m ) at the point λ m is:
[0085]
[0086] f2(λ m ) is expanded in Taylor series at λ m+1 , and formula (13) is substituted into formula (12) to obtain:
[0087]
[0088] Let λ m = λ m+1 , g(λ m+1 ) = 0, and the following formula can be obtained:
[0089]
[0090] Formula (15) is the iterative formula. Since g(λ m ) can be approximately expressed as f2(λ m ), λ m+1 in formula (15) is approximately the root of the function f2(λ m ) = 0. By continuously iterating λ m+1 , the final λ can be found, such that f2(λ m ) = 0, that is, the global optimal solution of formula (7).
[0091] In step S2084, the initial dimension correlation distance square sum ratio is obtained based on the optimization function and the initial dimension correlation matrix. The optimization function can be set to the maximum value, and the initial dimension correlation matrix is substituted to obtain the initial dimension correlation distance square sum ratio. The dimension correlation distance square sum of the sample pair is the trace of the dimension correlation distance matrix, wherein the dimension correlation distance matrix is obtained by multiplying the transpose of the dimension correlation matrix, the covariance matrix of the sample pair, and the dimension correlation matrix in sequence, as shown in formula (11), W m is the initial dimension correlation matrix, is the dimension correlation distance matrix of the sample pairs of different categories, is the dimension correlation distance matrix of the sample pairs of the same category, and the initial dimension correlation distance square sum ratio λ m is obtained by formula (11).
[0092] In step S2086, the initial dimension correlation matrix and the initial dimension correlation distance square sum ratio are respectively taken as the current dimension correlation matrix and the current dimension correlation distance square sum ratio.
[0093] Step S2088, the next dimension correlation matrix is obtained according to the current dimension correlation matrix, the covariance matrix of the sample pairs of the same category, the covariance matrix of the sample pairs of different categories and the current dimension correlation distance square sum ratio. The transpose of the current dimension correlation matrix, the difference between the product of the covariance matrix of the sample pairs of different categories and the current dimension correlation distance square sum ratio and the covariance matrix of the sample pairs of the same category, and the current dimension correlation matrix are sequentially multiplied to obtain an optimization square matrix; then the optimization square matrix is subjected to eigenvalue decomposition to obtain the next dimension correlation matrix. When performing eigenvalue decomposition, the optimization square matrix is subjected to eigenvalue decomposition to obtain a plurality of eigenvectors; then the plurality of eigenvectors are arranged according to the dimension of the current dimension correlation matrix to obtain the next dimension correlation matrix. According to formula (15), the optimization square matrix W m T (S w -λ m S b )W m Eigenvalue decomposition is performed to obtain n eigenvectors V1V2...V n The n eigenvectors are transversely arranged into the next dimension correlation matrix W m+1 .
[0094] Step S20810, the next dimension correlation matrix is substituted into the iteration formula to obtain the next dimension correlation distance square sum ratio.
[0095] Step S20812, the next dimension correlation matrix and the next dimension correlation distance square sum ratio are respectively taken as the current dimension correlation matrix and the current dimension correlation distance square sum ratio, and the steps of obtaining the next dimension correlation matrix and the steps of obtaining the next dimension correlation distance square sum ratio are iteratively executed until convergence. The judgment of convergence can be that the change of the current dimension correlation matrix W m is less than a preset threshold, or the change of the current dimension correlation distance square sum ratio λ m is less than a preset threshold.
[0096] According to the iterative operation method provided by the embodiments of the present disclosure, the initial dimension correlation matrix is substituted into the iteration formula obtained according to the optimization function to obtain the initial dimension correlation distance square sum ratio, and then the next dimension correlation matrix is obtained according to the current dimension correlation matrix, the covariance matrix of the sample pairs of the same category, the covariance matrix of the sample pairs of different categories and the current dimension correlation distance square sum ratio, and the above steps are iteratively executed until convergence, so that the distance between the sample pairs in the connected set is as small as possible, and the distance between the sample pairs in the unconnected set By using the largest possible dimensionality correlation matrix for the sample pairs, the dimensionality correlation matrix can be used to obtain the dimensionality correlation distance, which can then be used to calculate the Euclidean distance between different sample points in K-means clustering, thereby improving the accuracy of K-means clustering of the samples.
[0097] Figure 4 This is a schematic diagram illustrating an iterative algorithm flow according to an exemplary embodiment. For example... Figure 4 As shown, first input the number of features d for the selected data points, and the matrix S. w and S b (S402); Initialize and set m = 1 (S404); for W m T (S w -λ m S b W m Eigenvalue decomposition yields eigenvectors V1V2...V n Arrange the n feature vectors horizontally into W m+1 (S406); Order (S408); Repeat steps S406 to S408 until the algorithm converges, and output matrix A = W. * (W * ) T (S410).
[0098] Figure 5 This is a block diagram illustrating a data classification apparatus according to an exemplary embodiment. Figure 5 The device shown can be applied, for example, to the server side of the above system, or to the terminal device of the above system.
[0099] refer to Figure 5 The apparatus 50 provided in this embodiment may include a constraint set acquisition module 502, a covariance matrix acquisition module 504, an optimization function acquisition module 506, and a dimension correlation matrix acquisition module 508.
[0100] The constraint set acquisition module 502 can be used to acquire sample pairs of the same category and sample pairs of different categories.
[0101] The covariance matrix acquisition module 504 can be used to obtain the covariance matrix of sample pairs of the same class and the covariance matrix of sample pairs of different classes, respectively.
[0102] The optimization function acquisition module 506 can be used to obtain an optimization function based on the covariance matrix of sample pairs of the same class and the covariance matrix of sample pairs of different classes. The variables of the optimization function include the dimensional correlation matrix and the ratio of the sum of squared dimensional correlation distances between sample pairs of different classes and sample pairs of the same class.
[0103] The dimension correlation matrix obtaining module 508 can be configured to obtain an optimized dimension correlation matrix by iteratively updating the initial dimension correlation matrix towards a direction of a larger ratio of dimension correlation distance square sum, and perform classification on the data to be classified based on the optimized dimension correlation matrix.
[0104] Figure 6 is a block diagram of a data classification device according to an example embodiment. As shown, the device can be applied to the server side of the system described above, or can be applied to the terminal device of the system described above. Figure 6 The device shown can be applied to the server side of the system described above, or can be applied to the terminal device of the system described above.
[0105] With reference to Figure 6 The device 60 provided by the embodiments of the present disclosure can include a constraint set obtaining module 602, a covariance matrix obtaining module 604, an optimization function obtaining module 606, and a dimension correlation matrix obtaining module 608. The dimension correlation matrix obtaining module 608 can include an iterative obtaining module 6082, an initial ratio obtaining module 6084, a current quantity obtaining module 6086, a first iteration module 6088, a second iteration module 60810, and an iteration constraint module 60812. The first iteration module 6088 can include an optimization square matrix calculation module 60882 and a dimension correlation matrix calculation module 60884. The dimension correlation matrix calculation module 60884 can include an eigenvalue decomposition module 608842 and a dimension correlation matrix obtaining module 608844.
[0106] The constraint set obtaining module 602 can be configured to obtain sample pairs of the same category and sample pairs of different categories.
[0107] The covariance matrix obtaining module 604 can be configured to obtain the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories, respectively.
[0108] The optimization function obtaining module 606 can be configured to obtain an optimization function according to the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories. The variable of the optimization function includes the dimension correlation matrix and the ratio of the dimension correlation distance square sum of the sample pairs of different categories to the dimension correlation distance square sum of the sample pairs of the same category. The dimension correlation distance square sum of the sample pairs is the trace of the dimension correlation distance square matrix, where the dimension correlation distance square matrix is obtained by multiplying the transpose of the dimension correlation matrix, the covariance matrix of the sample pairs, and the dimension correlation matrix in sequence.
[0109] The optimization function obtaining module 606 can also be configured to establish a proportional relationship between the dimension correlation distance square sum of the sample pairs of different categories and the dimension correlation distance square sum of the sample pairs of the same category by using the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories, and obtain the optimization function.
[0110] The dimension correlation matrix obtaining module 608 can be configured to obtain an optimized dimension correlation matrix by iteratively updating the initial dimension correlation matrix in a direction of a larger dimension correlation distance square sum ratio value according to an optimization function, and perform classification on the data to be classified based on the optimized dimension correlation matrix.
[0111] The iterative formula obtaining module 6082 can be configured to obtain an iterative formula according to the optimization function, the iterative formula being used to represent an operation relationship between the dimension correlation distance square sum ratio value and the dimension correlation matrix, the covariance matrix of the sample pairs of the same category, and the covariance matrix of the sample pairs of different categories.
[0112] The initial ratio value obtaining module 6084 can be configured to obtain an initial dimension correlation distance square sum ratio value based on the optimization function according to the initial dimension correlation matrix.
[0113] The initial ratio value obtaining module 6084 can also be configured to take the maximum value of the optimization function, substitute the initial dimension correlation matrix, and calculate to obtain the initial dimension correlation distance square sum ratio value.
[0114] The current quantity obtaining module 6086 can be configured to take the initial dimension correlation matrix and the initial dimension correlation distance square sum ratio value as the current dimension correlation matrix and the current dimension correlation distance square sum ratio value, respectively.
[0115] The first iteration module 6088 can be configured to obtain a next dimension correlation matrix according to the current dimension correlation matrix, the covariance matrix of the sample pairs of the same category, the covariance matrix of the sample pairs of different categories, and the current dimension correlation distance square sum ratio value.
[0116] The optimization matrix calculating module 60882 can be configured to multiply the transpose of the current dimension correlation matrix, the difference between the product of the covariance matrix of the sample pairs of different categories and the current dimension correlation distance square sum ratio value and the covariance matrix of the sample pairs of the same category, and the current dimension correlation matrix in sequence to obtain an optimization matrix.
[0117] The dimension correlation matrix calculating module 60884 can be configured to perform eigenvalue decomposition on the optimization matrix to obtain the next dimension correlation matrix.
[0118] The eigenvalue decomposition module 608842 can be configured to perform eigenvalue decomposition on the optimization matrix to obtain a plurality of eigenvectors.
[0119] The dimension correlation matrix obtaining module 608844 can be configured to arrange the plurality of eigenvectors according to the dimension of the current dimension correlation matrix to obtain the next dimension correlation matrix.
[0120] The second iteration module 60810 can be configured to substitute the next dimension correlation matrix into the iteration formula to obtain a next dimension correlation distance square sum ratio.
[0121] The iteration constraint module 60812 can be configured to take the next dimension correlation matrix and the next dimension correlation distance square sum ratio as the current dimension correlation matrix and the current dimension correlation distance square sum ratio respectively, and iteratively execute the step of obtaining the next dimension correlation matrix by the first iteration module and the step of obtaining the next dimension correlation distance square sum ratio by the second iteration module until convergence.
[0122] The specific implementation of each module in the apparatus provided by the embodiments of the present disclosure can refer to the content in the above method, which will not be described here.
[0123] Figure 7 A structural schematic diagram of an electronic device in the embodiments of the present disclosure is shown. It should be noted that, Figure 7 The device shown is only an example of a computer system, and should not impose any limitation on the functions and use range of the embodiments of the present disclosure.
[0124] As Figure 7 shown, the device 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 702 or programs loaded from a storage portion 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0125] The following components are connected to the I / O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output portion 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), and the like, and a speaker, and the like; a storage portion 708 including a hard disk, and the like; and a communication portion 709 including a network interface card such as a LAN card, a modem, and the like. The communication portion 709 performs communication processing via a network such as the Internet. A drive 77 is also connected to the I / O interface 705 as necessary. A removable recording medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, and the like is attached to the drive 77 as necessary, so that a computer program read therefrom is installed in the storage portion 708 as necessary.
[0126] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program in accordance with embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer readable medium, the computer program comprising program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via the communication section 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-described functions defined in the system of the present disclosure are executed.
[0127] It should be noted that the computer readable medium shown in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. The computer readable storage medium may, for example, be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, 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 the present disclosure, the computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus or device. In the present disclosure, the computer readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer readable program code. Such a propagated data signal can take many forms, including but not limited to, an electromagnetic signal, an optical signal or any suitable combination of the above. The computer readable signal medium can also be any computer readable medium that can send, propagate or transfer a program for use by or in connection with an instruction execution system, apparatus or device. The program code contained on the computer readable medium can be transmitted by any suitable medium, including but not limited to wireless, wire, optical cable, RF or the like, or any suitable combination of the above.
[0128] The flow and block diagrams in the drawings represent possible architectural, functional, and operational architectures of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flow or block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flowchart illustrations, and combinations thereof, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0129] The modules involved in the embodiments of the present disclosure can be implemented in the form of software or in the form of hardware. The described modules can also be arranged in a processor, for example, a processor can be described as including a constraint set obtaining module, a covariance matrix obtaining module, an optimization function obtaining module, and a dimension correlation matrix obtaining module. In some cases, the names of these modules do not constitute a limitation on the modules themselves, for example, the constraint set obtaining module can also be described as a module that obtains sample pairs of the same category and sample pairs of different categories from a connected database.
[0130] As another aspect, the present disclosure also provides a computer readable medium, which can be included in the device described in the above embodiments, or can exist independently without being assembled into the device. The computer readable medium carries one or more programs, which, when executed by the device, cause the device to include: obtaining sample pairs of the same category and sample pairs of different categories; obtaining covariance matrices of the sample pairs of the same category and the sample pairs of different categories respectively; obtaining an optimization function according to the covariance matrices of the sample pairs of the same category and the sample pairs of different categories, the variables of the optimization function including a dimension correlation matrix and a ratio of the sum of the square distances of the dimension correlation to the sample pairs of different categories to the sample pairs of the same category; iteratively updating the initial dimension correlation matrix in the direction of a larger ratio of the sum of the square distances of the dimension correlation by the optimization function, to obtain an optimized dimension correlation matrix, and classifying the data to be classified based on the optimized dimension correlation matrix.
[0131] The exemplary embodiments of this disclosure are specifically illustrated and described herein. But, it is to be understood that the disclosure is not limited to the detailed construction, arrangements, or implementation methods described herein; rather, the disclosure is intended to cover any and all modifications and equivalent arrangements included within the spirit and scope of the appended claims.
Claims
1. A data classification method, characterized in that, Applied to a system including terminal devices, a server, and a database, the method includes: The system obtains sample pairs of the same category and sample pairs of different categories. The sample pairs of the same category include similar image pairs, and the sample pairs of different categories include dissimilar image pairs. The similar and dissimilar image pairs are obtained by the user marking similar and dissimilar images in the image retrieval results. The covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories are obtained respectively, wherein the samples in the sample pairs include features of multiple dimensions of image data; An optimization function is obtained based on the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories. The variables of the optimization function include the dimensionality correlation matrix and the ratio of the sum of squared dimensionality correlation distances between sample pairs of different categories and sample pairs of the same category. The initial dimensional correlation matrix is iteratively updated using the optimization function in the direction where the ratio of the sum of squared dimensional correlation distances is greater, to obtain an optimized dimensional correlation matrix, which is then used to classify the image data to be classified.
2. The method according to claim 1, characterized in that, The iterative update of the initial dimensional correlation matrix using the optimization function in the direction of increasing the ratio of the sum of squared dimensional correlation distances includes: An iterative formula is obtained based on the optimization function. The iterative formula is used to represent the operational relationship between the ratio of the squared sum of squared distances of the dimensional correlation and the dimensional correlation matrix, the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories. Based on the optimization function, the initial dimensional correlation distance sum of squares ratio is obtained according to the initial dimensional correlation matrix; The initial dimensional correlation matrix and the ratio of the initial dimensional correlation distance squared sum are respectively used as the current dimensional correlation matrix and the ratio of the current dimensional correlation distance squared sum; The next dimension correlation matrix is obtained based on the current dimension correlation matrix, the covariance matrix of the same category of sample pairs, the covariance matrix of different categories of sample pairs, and the ratio of the sum of squared distances of the current dimension correlation. Substitute the next dimension correlation matrix into the iterative formula to obtain the next dimension correlation distance squared ratio; The next-dimensional correlation matrix and the ratio of the squared distance of the next-dimensional correlation are used as the current-dimensional correlation matrix and the ratio of the squared distance of the current-dimensional correlation, respectively. The steps of obtaining the next-dimensional correlation matrix and obtaining the ratio of the squared distance of the next-dimensional correlation are iteratively executed until convergence.
3. The method according to claim 2, characterized in that, The step of obtaining the next dimension correlation matrix based on the current dimension correlation matrix, the covariance matrix of the same category of sample pairs, the covariance matrix of different categories of sample pairs, and the ratio of the sum of squared relevance distances of the current dimension includes: The optimized matrix is obtained by sequentially multiplying the transpose of the current dimension correlation matrix, the difference between the product of the covariance matrix of the different categories of sample pairs and the product of the ratio of the squared sum of the current dimension correlation distances and the covariance matrix of the same categories of sample pairs, and the current dimension correlation matrix. The optimized matrix is decomposed into eigenvalues to obtain the next-dimensional correlation matrix.
4. The method according to claim 3, characterized in that, The step of performing eigenvalue decomposition on the optimized matrix to obtain the next-dimensional correlation matrix includes: The optimized matrix is decomposed into eigenvalues to obtain multiple eigenvectors. The multiple feature vectors are arranged according to the dimension of the current dimension correlation matrix to obtain the next dimension correlation matrix.
5. The method according to claim 2, characterized in that, The step of obtaining the initial dimension correlation distance sum of squares ratio based on the initial dimension correlation matrix according to the optimization function includes: The optimization function is set to its maximum value, and the initial dimension correlation matrix is substituted into it to calculate the initial dimension correlation distance squared ratio.
6. The method according to any one of claims 2 to 5, characterized in that, The sum of squared dimensional correlation distances of sample pairs is the trace of the dimensional correlation distance matrix, which is obtained by multiplying the transpose of the dimensional correlation matrix, the covariance matrix of the sample pairs, and the dimensional correlation matrix in sequence.
7. The method according to any one of claims 1 to 5, characterized in that, The step of obtaining the optimization function based on the covariance matrix of the sample pairs of the same class and the covariance matrix of the sample pairs of different classes includes: By using the covariance matrices of sample pairs of the same category and sample pairs of different categories, the proportional relationship between the sum of squared dimensional correlation distances of sample pairs of different categories and the sum of squared dimensional correlation distances of sample pairs of the same category is established, and the optimization function is obtained.
8. A data classification device, characterized in that, The system is applied to a system including terminal devices, servers, and a database, and the device includes: The constraint set acquisition module is used to acquire sample pairs of the same category and sample pairs of different categories. The sample pairs of the same category include similar image pairs, and the sample pairs of different categories include dissimilar image pairs. The similar image pairs and dissimilar image pairs are obtained by the user marking similar and dissimilar images in the image retrieval results. The covariance matrix acquisition module is used to obtain the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories, wherein the samples in the sample pairs include features of multiple dimensions of image data. The optimization function acquisition module is used to obtain an optimization function based on the covariance matrix of the sample pairs of the same category and the covariance matrix of the sample pairs of different categories. The variables of the optimization function include the dimensional correlation matrix and the ratio of the sum of squared dimensional correlation distances between sample pairs of different categories and sample pairs of the same category. The dimensional correlation matrix acquisition module is used to iteratively update the initial dimensional correlation matrix in the direction of a larger ratio of the sum of squared dimensional correlation distances through the optimization function to obtain an optimized dimensional correlation matrix, so as to classify the image data to be classified based on the optimized dimensional correlation matrix.
9. An apparatus comprising: A memory, a processor, and executable instructions stored in the memory and executable in the processor, characterized in that the processor, when executing the executable instructions, implements the method as described in any one of claims 1-7.
10. A computer-readable storage medium having computer-executable instructions stored thereon, characterized in that, When the executable instructions are executed by the processor, they implement the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Traffic alarm condition level predication method based on distance metric learning
CN104834977A
Face image clustering method and device, computer equipment and storage medium
CN111985336A