Clustering method and device based on pairwise comparison results, storage medium and equipment
By generating weak and strong judgment matrices and using ROC curves to set threshold ranges, the pre-clustering grouping is corrected, solving the problem of high complexity in existing clustering algorithms and achieving fast and accurate sample clustering.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING TECHSHINO TECHNOLOGY CO LTD
- Filing Date
- 2022-04-28
- Publication Date
- 2026-06-30
AI Technical Summary
Existing clustering algorithms based on pairwise comparisons are complex, slow, and difficult to handle multiple similarity metrics flexibly.
By generating weak and strong decision matrices, setting threshold ranges using experimental ROC curves, obtaining preliminary clustering groups based on the weak decision matrices, and correcting them using the strong decision matrices, the algorithm complexity is reduced, and matrix calculations are used for fast clustering.
It reduces the complexity of clustering algorithms, improves clustering speed, and can flexibly handle multiple similarity indicators to achieve fast and accurate sample clustering.
Smart Images

Figure CN117036759B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image recognition, and in particular to a clustering method, apparatus, storage medium, and device based on pairwise comparison results. Background Technology
[0002] Clustering is the process of dividing a collection of physical or abstract objects into multiple classes composed of similar objects, such as image clustering. Clustering is an unsupervised classification process; no prior knowledge is available. A typical clustering process mainly includes steps such as data (or sample or pattern) preparation, feature selection and extraction, proximity calculation, clustering (or grouping), and evaluating the effectiveness of the clustering results.
[0003] Clustering algorithms based on pairwise comparisons are common clustering methods, such as hierarchical clustering. Hierarchical clustering includes two methods: aggregation (bottom-up) and splitting (top-down). Aggregation initially assigns each sample to its own cluster, then merges the two closest clusters to create a new cluster, repeating this process until a stopping condition is met, resulting in hierarchical categories. Splitting initially assigns all samples to a single cluster, then assigns the samples furthest apart from each existing cluster to two new clusters, repeating this process until a stopping condition is met, resulting in hierarchical categories.
[0004] Clustering algorithms based on pairwise comparisons have high complexity. For example, the complexity of hierarchical clustering is O(n log n). (n is the number of samples), which is relatively slow and requires setting merging rules and stopping conditions, and cannot flexibly handle multiple similarity indicators. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a clustering method, apparatus, storage medium, and device based on pairwise comparison results, which reduces algorithm complexity and improves clustering speed.
[0006] The technical solution provided by this invention is as follows:
[0007] In a first aspect, the present invention provides a clustering method based on pairwise comparison results, the method comprising:
[0008] Obtain at least one feature for each sample to be clustered, where the sample to be clustered is an image;
[0009] By performing pairwise comparisons of the same feature among all samples to be clustered, a comparison score matrix of at least one feature is obtained.
[0010] Based on the comparison score matrix of the at least one feature, a weak judgment matrix and a strong judgment matrix are generated. The element value at each position of the weak judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a first probability. The element value at each position of the strong judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a second probability. Wherein, the second probability is greater than the first probability.
[0011] The preliminary clustering groups are obtained based on the weak judgment matrix, and the preliminary clustering groups are corrected based on the strong judgment matrix to obtain the clustering grouping results.
[0012] Further, the step of generating a weak judgment matrix and a strong judgment matrix based on the comparison score matrix of the at least one feature, wherein each element value of the weak judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a first probability, and each element value of the strong judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a second probability, includes:
[0013] Set a first threshold range and a second threshold range for each feature;
[0014] Each alignment score in the alignment score matrix of each feature is compared with the first threshold range of that feature. If the alignment score at the same specific position in the alignment score matrix of each feature meets the first threshold range of that feature, then the element value at that specific position in the weak judgment matrix is set as the first value; otherwise, it is set as the second value.
[0015] Each alignment score in the alignment score matrix of each feature is compared with the second threshold range of that feature. If the alignment score at the same specific position in the alignment score matrix of each feature meets the second threshold range of that feature, then the element value at that specific position in the strong judgment matrix is set as the first value; otherwise, it is set as the second value.
[0016] Furthermore, setting the first threshold range and the second threshold range for each feature includes:
[0017] The ROC curve for each feature was obtained using experimental statistics;
[0018] For each feature, based on the ROC curve of that feature, obtain the first threshold range of that feature when the probability that two features of that feature belong to the same cluster group is the first probability;
[0019] For each feature, based on the ROC curve of that feature, obtain the second threshold range of that feature when the probability that two features of that feature belong to the same cluster group is the second probability.
[0020] Furthermore, the first value is 1, the second value is 0, the first probability is 0.9, and the second probability is 0.99.
[0021] Furthermore, the step of obtaining preliminary clustering groups based on the weak judgment matrix, and then correcting the preliminary clustering groups based on the strong judgment matrix to obtain the clustering grouping results includes:
[0022] Select the row with the most first values in the weak judgment matrix, and use the sample to be clustered corresponding to that row as the selected sample;
[0023] Based on the weak judgment matrix, the selected sample and the samples to be clustered that belong to the same cluster group as the selected sample are formed into preliminary cluster groups;
[0024] Based on the weak judgment matrix, samples that belong to the same cluster group as other samples to be clustered in the preliminary cluster group less than a first set value are removed from the preliminary cluster group to obtain the preliminary cluster group;
[0025] Based on the strong judgment matrix, samples that belong to the same cluster group as the samples to be clustered in the pre-clustering group a number of times that reaches a second set value are added to the pre-clustering group to obtain the corrected clustering group;
[0026] The modified clustering group is removed from the samples to be clustered, and the step of selecting the row with the most first values in the weak judgment matrix and taking the sample to be clustered corresponding to that row as the selected sample is repeated until the number of first values in each row of the weak judgment matrix corresponding to the remaining samples to be clustered is less than the third set value.
[0027] All the modified clustering groups constitute the clustering result.
[0028] Furthermore, the first set value is determined based on the percentage of the total number of samples to be clustered in the preliminary clustering group, and the second set value is greater than 1.
[0029] Furthermore, the method also includes:
[0030] The average of the pairwise comparison scores of each sample to be clustered within the modified clustering group is used as the first screening value of the modified clustering group, and the modified clustering groups that do not meet the first screening value are removed.
[0031] And, or;
[0032] The average score of any sample to be clustered outside the modified clustering group and all samples to be clustered within the modified clustering group is calculated as the second screening value. Samples to be clustered that meet the second screening value and the second set condition are added to the modified clustering group.
[0033] And, or;
[0034] Corrected clustering groups with a total number of samples to be clustered that is less than the set number of samples will be removed.
[0035] Secondly, the present invention provides a clustering device based on pairwise comparison results, the device comprising:
[0036] The feature acquisition module is used to acquire at least one feature for each sample to be clustered, wherein the sample to be clustered is an image;
[0037] The comparison score matrix determination module is used to perform pairwise comparisons of the same feature of all samples to be clustered to obtain the comparison score matrix of the at least one feature.
[0038] The strong / weak judgment matrix determination module is used to generate a weak judgment matrix and a strong judgment matrix based on the comparison score matrix of the at least one feature. The element value of each position in the weak judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a first probability. The element value of each position in the strong judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a second probability. The second probability is greater than the first probability.
[0039] The clustering grouping module is used to obtain preliminary clustering groups based on the weak judgment matrix, and to correct the preliminary clustering groups based on the strong judgment matrix to obtain the clustering grouping results.
[0040] Furthermore, the strength judgment matrix determination module includes:
[0041] A threshold range setting unit is used to set a first threshold range and a second threshold range for each feature;
[0042] The weak judgment matrix determination unit is used to compare each comparison score in the comparison score matrix of each feature with the first threshold range of that feature. If the comparison score at the same specific position in the comparison score matrix of each feature meets the first threshold range of that feature, then the element value at that specific position of the weak judgment matrix is set to the first value; otherwise, it is set to the second value.
[0043] The strong judgment matrix determination unit is used to compare each comparison score in the comparison score matrix of each feature with the second threshold range of that feature. If the comparison score at the same specific position in the comparison score matrix of each feature meets the second threshold range of that feature, then the element value at that specific position in the strong judgment matrix is set to the first value; otherwise, it is set to the second value.
[0044] Furthermore, the threshold range setting unit includes:
[0045] The statistical unit is used to obtain the ROC curve for each feature using experimental statistics;
[0046] The first threshold range determination unit is used to obtain, for each feature, the first threshold range of the feature when the probability that two features of that feature belong to the same cluster group is the first probability, based on the ROC curve of that feature.
[0047] The second threshold range determination unit is used to obtain, for each feature, the second threshold range of the feature corresponding to the probability that two features of that feature belong to the same cluster group is the second probability, based on the ROC curve of that feature.
[0048] Furthermore, the first value is 1, the second value is 0, the first probability is 0.9, and the second probability is 0.99.
[0049] Furthermore, the clustering and grouping module includes:
[0050] The selected unit is used to select the row with the most first values in the weak judgment matrix, and the sample to be clustered corresponding to that row is the selected sample.
[0051] The preliminary clustering grouping determination unit is used to form preliminary clustering groups based on the weak judgment matrix, consisting of the selected sample and the samples to be clustered that belong to the same clustering group as the selected sample.
[0052] The preliminary clustering grouping determination unit is used to remove, based on the weak judgment matrix, samples to be clustered from the preliminary clustering group whose number of times they belong to the same clustering group as other samples to be clustered in the preliminary clustering group is less than a first set value, thereby obtaining the preliminary clustering grouping;
[0053] The modified clustering grouping determination unit is used to add to the pre-clustering group samples that belong to the same clustering group as the samples to be clustered in the pre-clustering group a number of times that reaches a second set value, based on the strong judgment matrix, to obtain the modified clustering group;
[0054] The loop unit is used to remove the modified clustering group from the samples to be clustered and return to the selected unit until the number of the first values in each row of the weak judgment matrix corresponding to the remaining samples to be clustered is less than the third set value.
[0055] All the modified clustering groups constitute the clustering result.
[0056] Furthermore, the first set value is determined based on the percentage of the total number of samples to be clustered in the preliminary clustering group, and the second set value is greater than 1.
[0057] Furthermore, the device also includes:
[0058] The first elimination module is used to calculate the average of the pairwise comparison scores of each sample to be clustered within the corrected clustering group as the first screening value of the corrected clustering group, and to eliminate the corrected clustering group whose first screening value does not meet the first set condition.
[0059] And, or;
[0060] The "missing sample" module is used to calculate the average comparison score between any sample to be clustered outside the modified clustering group and all samples to be clustered within the modified clustering group as a second screening value, and to add samples to be clustered that meet the second screening value and the second set condition to the modified clustering group;
[0061] And, or;
[0062] The second elimination module is used to eliminate modified clustering groups whose total number of samples to be clustered is less than a set number of samples.
[0063] The present invention has the following beneficial effects:
[0064] This invention generates weak and strong judgment matrices based on the pairwise comparison score matrices obtained from comparing samples to be clustered. Each element in both matrices indicates whether the two samples at that position belong to the same cluster group with a corresponding probability. Then, preliminary clustering groups are obtained based on the weak judgment matrix, and these groups are refined using the strong judgment matrix to obtain the final clustering result. Compared to hierarchical clustering, this method reduces algorithmic complexity and enables rapid clustering. Furthermore, the entire clustering process utilizes matrix calculations, making computation faster and more efficient. It eliminates the need to set merging rules and stopping conditions; multiple comparison features can be selected, allowing for flexible adjustment of the strong and weak judgment matrices; it can flexibly handle multiple similarity indices, enabling rapid and accurate clustering of samples. Attached Figure Description
[0065] Figure 1 This is a flowchart of the clustering method based on pairwise comparison results of the present invention.
[0066] Figure 2 This is a schematic diagram of the clustering device based on pairwise comparison results of the present invention. Detailed Implementation
[0067] To make the technical problems, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. The components of the embodiments of this invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without inventive effort are within the scope of protection of this invention.
[0068] This invention provides a clustering method based on pairwise comparison results, such as... Figure 1 As shown, the method includes:
[0069] S100: Obtain at least one feature for each sample to be clustered.
[0070] The samples to be clustered in this invention can be images, such as facial images in biometric recognition. This invention can be applied in various scenarios, including but not limited to the examples listed below.
[0071] For example, in a large number of images, dozens may be taken by different people in the same scene, while the backgrounds of the other images vary. By using image analysis techniques, we can obtain background similarity scores for each pair of images (similarity scores can be categorized into multiple groups, such as color similarity, texture similarity, etc.), accurately and quickly clustering the target image groups and avoiding redundant grouping.
[0072] For example, by performing cluster analysis on massive amounts of images, images containing faces are grouped, and the grouping results determine that images within the same group have the same life trajectory.
[0073] Each sample to be clustered can have one or more features. The appropriate feature should be selected based on the actual requirements. When multiple features are selected, multiple similarity indicators can be referenced simultaneously for clustering, making the clustering results more accurate.
[0074] S200: Perform pairwise comparisons of the same feature among all samples to be clustered to obtain a comparison score matrix for at least one feature.
[0075] For all samples to be clustered, pairwise comparisons of the same feature are performed to obtain a comparison score matrix, with one comparison score matrix corresponding to each feature. The value at each element position in the comparison score matrix represents the comparison score of the corresponding two samples to be clustered, and the comparison score can be represented by similarity.
[0076] Different alignment algorithms produce different alignment scores. In some cases, a higher alignment score indicates a higher similarity, while in other cases, a higher alignment score indicates a lower similarity.
[0077] Suppose the list of names of the samples (images) to be clustered is: ['BG2-03', 'BG2-05', 'BG2-07', 'Other-06', 'Others02-035', 'Others02-123', 'Others02-059'], where BG2-xx are images with the same background, and the other images have different backgrounds.
[0078] Assuming the samples to be clustered have two types of features, namely the first feature and the second feature, the pairwise comparison of the first feature of all samples to be clustered yields the following comparison score matrix:
[0079]
[0080] By performing pairwise comparisons of the second feature of all samples to be clustered, the comparison score matrix of the first feature is obtained as follows:
[0081]
[0082] In both the first and second features, the lower the comparison score, the higher the similarity.
[0083] S300: Based on the comparison score matrix of the at least one feature, generate a weak judgment matrix and a strong judgment matrix. The element value of each position of the weak judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a first probability. The element value of each position of the strong judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a second probability. Wherein, the second probability is greater than the first probability.
[0084] The element value at each position in both the weak and strong judgment matrices indicates whether the two samples to be clustered at that position belong to the same cluster group with a corresponding probability; that is, whether they are paired. Pairing can be represented by different numbers. The strong judgment matrix represents a greater probability of pairing than the weak judgment matrix, meaning the weak judgment matrix provides a more comprehensive result regarding pairing, while the strong judgment matrix provides a more accurate result.
[0085] S400: Obtain preliminary clustering groups based on the weak judgment matrix, and correct the preliminary clustering groups based on the strong judgment matrix to obtain the clustering grouping results.
[0086] As mentioned above, the weak judgment matrix and the strong judgment matrix indicate whether the corresponding samples to be clustered are paired. Therefore, based on the two matrices, similar samples to be clustered can be clustered into one class, and the clustering grouping results can be obtained.
[0087] During clustering, since the weak judgment matrix represents the pairing results more comprehensively, it can be used to obtain preliminary clustering groups, so that the samples to be clustered are clustered into the preliminary clustering groups as comprehensively as possible. On the other hand, the strong judgment matrix represents the pairing results more accurately, so the preliminary clustering groups can be modified according to the strong judgment matrix, so that the modified clustering grouping results are more accurate.
[0088] For example, for the aforementioned samples to be clustered ['BG2-03', 'BG2-05', 'BG2-07', 'Other-06', 'Others02-035', 'Others02-123', 'Others02-059'], the clustering grouping result is: [['BG2-03', 'BG2-05', 'BG2-07']].
[0089] This invention generates weak and strong judgment matrices based on the pairwise comparison score matrices obtained from comparing samples to be clustered. Each element in both matrices indicates whether the two samples at that position belong to the same cluster group with a corresponding probability. Then, preliminary clustering groups are obtained based on the weak judgment matrix, and these groups are refined using the strong judgment matrix to obtain the final clustering result. Compared to hierarchical clustering, this method reduces algorithmic complexity and enables rapid clustering. Furthermore, the entire clustering process utilizes matrix calculations, making computation faster and more efficient. It eliminates the need to set merging rules and stopping conditions; multiple comparison features can be selected, allowing for flexible adjustment of the strong and weak judgment matrices; it can flexibly handle multiple similarity indices, enabling rapid and accurate clustering of samples.
[0090] In one example, the aforementioned S300 includes:
[0091] S310: Set the first threshold range and the second threshold range for each feature.
[0092] The setting of the first and second threshold ranges can be determined based on experience or experimental statistics. When determining them based on experimental statistics, the following methods are included:
[0093] S311: Obtain the ROC curve for each feature using experimental statistics.
[0094] S312: For each feature, based on the ROC curve of that feature, obtain the first threshold range of that feature when the probability that two features of that feature belong to the same cluster group is the first probability.
[0095] S313: For each feature, based on the ROC curve of that feature, obtain the second threshold range of that feature when the probability that two features of that feature belong to the same cluster group is the second probability.
[0096] Assuming the samples to be clustered have two types of features (a first feature and a second feature), when the comparison score is higher and the similarity is higher, if the comparison score of the first feature of sample a and the first feature of sample b is greater than T1, then the probability that sample a and sample b belong to the same group is the first probability. Therefore, the first threshold range for the first feature is "greater than T1". Similarly, when the comparison score is higher and the similarity is lower, the first threshold range for the first feature is "less than T1". Likewise, the first threshold range for the second feature can be obtained.
[0097] When the comparison score is higher and the similarity is higher, if the comparison score between the first feature of sample a and the first feature of sample b is greater than T2, then the probability that sample a and sample b belong to the same group is the second probability. Therefore, the second threshold range for the first feature is "greater than T2". Similarly, when the comparison score is higher and the similarity is lower, the second threshold range for the first feature is "less than T2". Likewise, the second threshold range for the second feature can be obtained.
[0098] The first probability can be 90%, and the second probability can be 99%.
[0099] S320: Compare each alignment score in the alignment score matrix of each feature with the first threshold range of that feature. If the alignment score at the same specific position in the alignment score matrix of each feature meets the first threshold range of that feature, then set the element value at that specific position of the weak judgment matrix as the first value; otherwise, set it as the second value.
[0100] S340: Compare each alignment score in the alignment score matrix of each feature with the second threshold range of that feature. If the alignment score at the same specific position in the alignment score matrix of each feature meets the second threshold range of that feature, then set the element value at that specific position of the strong judgment matrix as the first value; otherwise, set it as the second value.
[0101] The first value can be 1, and the second value can be 0.
[0102] Based on the pairwise comparison score matrix, this invention generates a weak judgment matrix (paired is 1, unpaired is 0) according to a first threshold range of 90% with a first probability (obtained from experimental ROC curve); and generates a strong judgment matrix (paired is 1, unpaired is 0) according to a second threshold range of 99% with a second probability (obtained from experimental ROC curve).
[0103] For example:
[0104] Suppose that for the first feature, the first threshold range is "less than 0.7", and for the second feature, the first threshold range is "less than 0.16". In this case, the recall rate is 0.97, and the precision rate is 0.90 (i.e., the first probability). Then, for the comparison score matrix of the first and second features mentioned above, the weak judgment matrix is:
[0105]
[0106] Assuming that for the first feature, the second threshold range is "less than 0.7", and for the second feature, the second threshold range is "less than 0.088", then the recall rate is 0.82 and the precision rate is 0.99 (i.e., the second probability). Then, for the comparison score matrix of the aforementioned first and second features, the strong judgment matrix is:
[0107]
[0108] This invention makes extensive use of the ROC curves obtained from experiments to set up a strength judgment matrix, which is more accurate.
[0109] Accordingly, the aforementioned S400 may include:
[0110] S410: Select the row with the most first values in the weak judgment matrix, and take the sample to be clustered corresponding to that row as the selected sample.
[0111] For example, when the first value is 1, the row i with the most 1s in the weak judgment matrix can be selected to obtain the selected sample i, which is the sample to be clustered with the most pairings in the weak judgment matrix.
[0112] S420: Based on the weak judgment matrix, the selected sample and the samples to be clustered that belong to the same cluster group as the selected sample are grouped into preliminary cluster groups.
[0113] The samples to be clustered that belong to the same cluster group as the selected sample are the samples paired with the selected sample. In other words, in the weak decision matrix, the sample to be clustered is the column corresponding to the position of the element with a value of 1 in the i-th row. These samples to be clustered and the selected sample form the initial cluster group A.
[0114] S430: Based on the weak judgment matrix, remove samples from the preliminary clustering group that belong to the same clustering group less than a first set value, thereby obtaining the preliminary clustering group.
[0115] In this step, we can first use the weak decision matrix to count the number of times each sample to be clustered in the preliminary clustering group belongs to the same cluster group as other samples to be clustered in the preliminary clustering group (i.e., the number of pairings). Then, we determine whether the number of pairings is less than a first set value. If it is less, it means that the sample to be clustered is not very similar to other samples to be clustered and is not in the same class. The sample to be clustered should be removed. After removal, we obtain the preliminary clustering group B.
[0116] The first set value can be determined based on the percentage of the total number of samples to be clustered |A| in the preliminary clustering group A. For example, it can be set to a value of .
[0117] S440: Based on the strong judgment matrix, add the samples to be clustered that belong to the same cluster group as the samples to be clustered in the pre-clustering group the number of times they reach the second set value, to the pre-clustering group, to obtain the corrected clustering group.
[0118] After obtaining the preliminary clustering group, some of the remaining samples to be clustered may also belong to the preliminary clustering group, and should be added to the preliminary clustering group. Based on the strong judgment matrix, this invention selects samples from the remaining samples to be clustered (not in group B) whose number of times they belong to the same clustering group as the samples to be clustered in group B (i.e., the number of pairings) reaches a second preset value. These selected samples are similar to the samples to be clustered in the preliminary clustering group B, and should be placed in B to obtain the modified clustering group C.
[0119] The value of the second setting can be set as needed. In one example, the value of the second setting is greater than 1, such as 2 or 3.
[0120] S450: Remove the modified clustering group from the samples to be clustered, and return to S410, until the number of first values in each row of the weak judgment matrix corresponding to the remaining samples to be clustered is less than the third set value.
[0121] After obtaining a corrected clustering group C, remove the corrected clustering group C from all samples to be clustered, and repeat steps S410 to S450 until the number of first values in each row of the weak judgment matrix corresponding to the remaining samples to be clustered is less than a third preset value. In other words, the maximum number of pairs of the remaining samples to be clustered is less than the third preset value, which can be determined according to actual needs. That is, the remaining samples to be clustered are less than a certain number (the third preset value) and can no longer be classified into one class, so the clustering process ends. After the clustering process ends, all the obtained corrected clustering groups constitute the clustering result.
[0122] The clustering process of this invention selects groups according to the number of pairs, and the entire selection process is sorted according to the number of matches, regardless of the comparison order; the clustering calculation is based on binary (0, 1) weak and strong judgment matrices, and the complexity of this algorithm is O(n log n). It has low complexity, and because binary matrix operations are very fast, it can be quickly grouped.
[0123] After obtaining the corrected clustering groups, you can also select the following S500~S700 to perform operations such as elimination and omission of the corrected clustering groups as needed. S500~S700 can be flexibly selected according to the actual situation, or even omitted.
[0124] S500: Calculate the average of the pairwise comparison scores of each sample to be clustered within the modified clustering group as the first screening value of the modified clustering group, and remove the modified clustering group whose first screening value does not meet the first set condition.
[0125] This step is used to remove invalid groups: The first set condition can be obtained from experimental testing. Taking the higher the comparison score as the lower the similarity, if the average of the pairwise comparison scores of each sample to be clustered in the modified cluster group meets the first set condition (i.e., greater than a certain value), it means that the samples to be clustered in the modified cluster group are not similar, the modified cluster group is invalid, and the modified cluster group needs to be removed.
[0126] S600: Calculate the average of the comparison scores between any sample to be clustered outside the modified clustering group and all samples to be clustered within the modified clustering group as the second screening value, and add the samples to be clustered that meet the second screening value and the second set conditions to the modified clustering group.
[0127] This step is used to identify omissions: The second set condition can be obtained from experimental testing. Taking the example that the higher the comparison score, the lower the similarity, if there is a sample to be clustered and the average comparison score of all samples to be clustered in the modified clustering group meets the second set condition (i.e., less than a certain value), it means that the sample to be clustered is similar to each sample to be clustered in the modified clustering group and needs to be added to the modified clustering group.
[0128] S700: Remove modified clustering groups whose total number of samples to be clustered is less than the set number of samples.
[0129] This step is used to remove modified clustering groups that do not meet the requirements. Modified clustering groups with a total number of samples less than the set number (adjustable according to actual needs) can be removed based on the actual required total number of samples within the clustering group.
[0130] This invention also provides a clustering device based on pairwise comparison results, such as... Figure 2 As shown, the device includes:
[0131] Feature acquisition module 1 is used to acquire at least one feature for each sample to be clustered, wherein the sample to be clustered is an image.
[0132] The comparison score matrix determination module 2 is used to perform pairwise comparisons of the same feature of all samples to be clustered to obtain the comparison score matrix of at least one feature.
[0133] The strong / weak judgment matrix determination module 3 is used to generate a weak judgment matrix and a strong judgment matrix based on the comparison score matrix of the at least one feature. The element value of each position of the weak judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a first probability. The element value of each position of the strong judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a second probability. The second probability is greater than the first probability.
[0134] Clustering grouping module 4 is used to obtain preliminary clustering groups based on the weak judgment matrix, and to correct the preliminary clustering groups based on the strong judgment matrix to obtain the clustering grouping results.
[0135] This invention generates weak and strong judgment matrices based on the pairwise comparison score matrices obtained from comparing samples to be clustered. Each element in both matrices indicates whether the two samples at that position belong to the same cluster group with a corresponding probability. Then, preliminary clustering groups are obtained based on the weak judgment matrix, and these groups are refined using the strong judgment matrix to obtain the final clustering result. Compared to hierarchical clustering, this method reduces algorithmic complexity and enables rapid clustering. Furthermore, the entire clustering process utilizes matrix calculations, making computation faster and more efficient. It eliminates the need to set merging rules and stopping conditions; multiple comparison features can be selected, allowing for flexible adjustment of the strong and weak judgment matrices; it can flexibly handle multiple similarity indices, enabling rapid and accurate clustering of samples.
[0136] In one example, the strength judgment matrix determination module includes:
[0137] The threshold range setting unit is used to set the first threshold range and the second threshold range for each feature.
[0138] The weak judgment matrix determination unit is used to compare each comparison score in the comparison score matrix of each feature with the first threshold range of that feature. If the comparison score of the same specific position in the comparison score matrix of each feature meets the first threshold range of that feature, then the element value of the specific position of the weak judgment matrix is set to the first value; otherwise, it is set to the second value.
[0139] The strong judgment matrix determination unit is used to compare each comparison score in the comparison score matrix of each feature with the second threshold range of that feature. If the comparison score at the same specific position in the comparison score matrix of each feature meets the second threshold range of that feature, then the element value at that specific position in the strong judgment matrix is set to the first value; otherwise, it is set to the second value.
[0140] The threshold range setting unit may include:
[0141] The statistical unit is used to obtain the ROC curve for each feature using experimental statistics;
[0142] The first threshold range determination unit is used to obtain, for each feature, the first threshold range of the feature when the probability that two features of that feature belong to the same cluster group is the first probability, based on the ROC curve of that feature.
[0143] The second threshold range determination unit is used to obtain, for each feature, the second threshold range of the feature corresponding to the probability that two features of that feature belong to the same cluster group is the second probability, based on the ROC curve of that feature.
[0144] The first value can be 1, the second value can be 0, the first probability can be 0.9, and the second probability can be 0.99.
[0145] The aforementioned clustering and grouping module may include:
[0146] The selected unit is used to select the row with the most first values in the weak judgment matrix, and the sample to be clustered corresponding to that row is selected as the selected sample.
[0147] The preliminary clustering grouping determination unit is used to form preliminary clustering groups based on the weak judgment matrix, consisting of the selected sample and the samples to be clustered that belong to the same clustering group as the selected sample.
[0148] The preliminary clustering grouping determination unit is used to remove, based on the weak judgment matrix, samples from the preliminary clustering group that belong to the same clustering group less than a first set value, thereby obtaining the preliminary clustering grouping.
[0149] The modified clustering group determination unit is used to add to the pre-clustering group samples that belong to the same clustering group as the samples to be clustered in the pre-clustering group a number of times that reaches a second preset value, based on the strong judgment matrix, so as to obtain the modified clustering group.
[0150] The loop unit is used to remove the modified clustering group from the samples to be clustered and return to the selected unit until the number of the first values in each row of the weak judgment matrix corresponding to the remaining samples to be clustered is less than a third set value.
[0151] All the modified clustering groups constitute the clustering result.
[0152] The first setting value can be determined based on the percentage of the total number of samples to be clustered in the preliminary clustering group, and the second setting value is greater than 1.
[0153] The device may further include:
[0154] The first elimination module is used to calculate the average of the pairwise comparison scores of each sample to be clustered within the corrected clustering group as the first screening value of the corrected clustering group, and to eliminate corrected clustering groups whose first screening value does not meet the first set condition.
[0155] And, or;
[0156] The "missing sample" module is used to calculate the average of the comparison scores between any sample to be clustered outside the modified clustering group and all samples to be clustered within the modified clustering group as the second screening value, and to add samples to be clustered that meet the second screening value and the second set conditions to the modified clustering group.
[0157] And, or;
[0158] The second elimination module is used to eliminate modified clustering groups whose total number of samples to be clustered is less than a set number of samples.
[0159] The apparatus provided in this embodiment of the invention operates on the same principle and produces the same technical effects as the aforementioned method embodiments. For the sake of brevity, any parts not mentioned in this apparatus embodiment can be referred to the corresponding content in the aforementioned method embodiments. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the apparatus and units described above can all be referred to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0160] The methods described in the above embodiments of the present invention can implement business logic through a computer program and record it on a storage medium. The storage medium can be read and executed by a computer, achieving the effects of the scheme described in the method embodiments of this specification. Therefore, the embodiments of the present invention also provide a computer-readable storage medium for clustering, including a memory for storing processor-executable instructions. When the instructions are executed by the processor, they implement the steps of the clustering method based on pairwise comparison results of the foregoing embodiments.
[0161] This invention generates weak and strong judgment matrices based on the pairwise comparison score matrices obtained from comparing samples to be clustered. Each element in both matrices indicates whether the two samples at that position belong to the same cluster group with a corresponding probability. Then, preliminary clustering groups are obtained based on the weak judgment matrix, and these groups are refined using the strong judgment matrix to obtain the final clustering result. Compared to hierarchical clustering, this method reduces algorithmic complexity and enables rapid clustering. Furthermore, the entire clustering process utilizes matrix calculations, making computation faster and more efficient. It eliminates the need to set merging rules and stopping conditions; multiple comparison features can be selected, allowing for flexible adjustment of the strong and weak judgment matrices; it can flexibly handle multiple similarity indices, enabling rapid and accurate clustering of samples.
[0162] The storage medium may include a physical device for storing information, typically digitizing the information and then storing it using electrical, magnetic, or optical methods. The storage medium may include: devices that store information using electrical energy, such as various types of memory, like RAM and ROM; devices that store information using magnetic energy, such as hard disks, floppy disks, magnetic tapes, magnetic core memory, bubble memory, and USB flash drives; and devices that store information using optical methods, such as CDs or DVDs. Of course, there are other readable storage media, such as quantum memories and graphene memories.
[0163] The storage medium described above may also include other implementation methods according to the description of the method embodiments. The implementation principle and technical effects of this embodiment are the same as those of the foregoing method embodiments. For details, please refer to the description of the relevant method embodiments, which will not be repeated here.
[0164] This invention also provides a clustering device. The device can be a standalone computer, or it can include an actual operating device that uses one or more of the methods or embodiments described in this specification. The device may include at least one processor and a memory storing computer-executable instructions. When the processor executes the instructions, it implements the steps of any one or more of the clustering methods based on pairwise comparison results described above.
[0165] This invention generates weak and strong judgment matrices based on the pairwise comparison score matrices obtained from comparing samples to be clustered. Each element in both matrices indicates whether the two samples at that position belong to the same cluster group with a corresponding probability. Then, preliminary clustering groups are obtained based on the weak judgment matrix, and these groups are refined using the strong judgment matrix to obtain the final clustering result. Compared to hierarchical clustering, this method reduces algorithmic complexity and enables rapid clustering. Furthermore, the entire clustering process utilizes matrix calculations, making computation faster and more efficient. It eliminates the need to set merging rules and stopping conditions; multiple comparison features can be selected, allowing for flexible adjustment of the strong and weak judgment matrices; it can flexibly handle multiple similarity indices, enabling rapid and accurate clustering of samples.
[0166] The device described above may also include other implementation methods according to the method embodiments. The implementation principle and technical effects of this embodiment are the same as those of the foregoing method embodiments. For details, please refer to the description of the relevant method embodiments, which will not be repeated here.
[0167] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the scope of the technology disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. All should be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A clustering method based on pairwise comparison results, characterized in that, The method includes: Obtain at least one feature for each sample to be clustered, where the sample to be clustered is an image; By performing pairwise comparisons of the same feature among all samples to be clustered, a comparison score matrix of at least one feature is obtained. Based on the comparison score matrix of the at least one feature, a weak judgment matrix and a strong judgment matrix are generated. The element value at each position of the weak judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a first probability. The element value at each position of the strong judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a second probability. Wherein, the second probability is greater than the first probability. The preliminary clustering groups are obtained based on the weak judgment matrix, and the preliminary clustering groups are corrected based on the strong judgment matrix to obtain the clustering grouping results. The step of generating a weak judgment matrix and a strong judgment matrix based on the comparison score matrix of the at least one feature, wherein each element value of the weak judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a first probability, and each element value of the strong judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a second probability, including: Set a first threshold range and a second threshold range for each feature; Each alignment score in the alignment score matrix of each feature is compared with the first threshold range of that feature. If the alignment score at the same specific position in the alignment score matrix of each feature meets the first threshold range of that feature, then the element value at that specific position in the weak judgment matrix is set as the first value; otherwise, it is set as the second value. Each alignment score in the alignment score matrix of each feature is compared with the second threshold range of that feature. If the alignment score at the same specific position in the alignment score matrix of each feature meets the second threshold range of that feature, then the element value at that specific position in the strong judgment matrix is set to the first value; otherwise, it is set to the second value. The process of obtaining preliminary clustering groups based on the weak judgment matrix, and then refining the preliminary clustering groups based on the strong judgment matrix to obtain the clustering grouping results includes: Select the row with the most first values in the weak judgment matrix, and use the sample to be clustered corresponding to that row as the selected sample; Based on the weak judgment matrix, the selected sample and the samples to be clustered that belong to the same cluster group as the selected sample are formed into preliminary cluster groups; Based on the weak judgment matrix, samples that belong to the same cluster group as other samples to be clustered in the preliminary cluster group less than a first set value are removed from the preliminary cluster group to obtain the preliminary cluster group; Based on the strong judgment matrix, samples that belong to the same cluster group as the samples to be clustered in the pre-clustering group a number of times that reaches a second set value are added to the pre-clustering group to obtain the corrected clustering group; The modified clustering group is removed from the samples to be clustered, and the step of selecting the row with the most first values in the weak judgment matrix and taking the sample to be clustered corresponding to that row as the selected sample is repeated until the number of first values in each row of the weak judgment matrix corresponding to the remaining samples to be clustered is less than the third set value. All the modified clustering groups constitute the clustering result.
2. The clustering method based on pairwise comparison results according to claim 1, characterized in that, The setting of a first threshold range and a second threshold range for each feature includes: The ROC curve for each feature was obtained using experimental statistics; For each feature, based on the ROC curve of that feature, obtain the first threshold range of that feature when the probability that two features of that feature belong to the same cluster group is the first probability; For each feature, based on the ROC curve of that feature, obtain the second threshold range of that feature when the probability that two features of that feature belong to the same cluster group is the second probability.
3. The clustering method based on pairwise comparison results according to claim 2, characterized in that, The first value is 1, the second value is 0, the first probability is 0.9, and the second probability is 0.
99.
4. The clustering method based on pairwise comparison results according to claim 1, characterized in that, The first setting value is determined based on the percentage of the total number of samples to be clustered in the preliminary clustering group, and the second setting value is greater than 1.
5. The clustering method based on pairwise comparison results according to claim 4, characterized in that, The method further includes: The average of the pairwise comparison scores of each sample to be clustered within the modified clustering group is used as the first screening value of the modified clustering group, and the modified clustering groups that do not meet the first screening value are removed. And, or; The average score of any sample to be clustered outside the modified clustering group and all samples to be clustered within the modified clustering group is calculated as the second screening value. Samples to be clustered that meet the second screening value and the second set condition are added to the modified clustering group. And, or; Corrected clustering groups with a total number of samples to be clustered that is less than the set number of samples will be removed.
6. A clustering device based on pairwise comparison results, characterized in that, The device includes: The feature acquisition module is used to acquire at least one feature for each sample to be clustered, wherein the sample to be clustered is an image; The comparison score matrix determination module is used to perform pairwise comparisons of the same feature of all samples to be clustered to obtain the comparison score matrix of the at least one feature. The strong / weak judgment matrix determination module is used to generate a weak judgment matrix and a strong judgment matrix based on the comparison score matrix of the at least one feature. The element value of each position in the weak judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a first probability. The element value of each position in the strong judgment matrix represents whether the two samples to be clustered at that position belong to the same cluster group under a second probability. The second probability is greater than the first probability. The clustering grouping module is used to obtain preliminary clustering groups based on the weak judgment matrix, and to correct the preliminary clustering groups based on the strong judgment matrix to obtain the clustering grouping results. The strength judgment matrix determination module includes: A threshold range setting unit is used to set a first threshold range and a second threshold range for each feature; The weak judgment matrix determination unit is used to compare each comparison score in the comparison score matrix of each feature with the first threshold range of that feature. If the comparison score at the same specific position in the comparison score matrix of each feature meets the first threshold range of that feature, then the element value at that specific position of the weak judgment matrix is set to the first value; otherwise, it is set to the second value. The strong judgment matrix determination unit is used to compare each comparison score in the comparison score matrix of each feature with the second threshold range of that feature. If the comparison score at the same specific position in the comparison score matrix of each feature meets the second threshold range of that feature, then the element value at that specific position in the strong judgment matrix is set to the first value; otherwise, it is set to the second value. The clustering grouping module includes: The selected unit is used to select the row with the most first values in the weak judgment matrix, and the sample to be clustered corresponding to that row is the selected sample. The preliminary clustering grouping determination unit is used to form preliminary clustering groups based on the weak judgment matrix, consisting of the selected sample and the samples to be clustered that belong to the same clustering group as the selected sample. The preliminary clustering grouping determination unit is used to remove, based on the weak judgment matrix, samples to be clustered from the preliminary clustering group whose number of times they belong to the same clustering group as other samples to be clustered in the preliminary clustering group is less than a first set value, thereby obtaining the preliminary clustering grouping; The modified clustering grouping determination unit is used to add to the pre-clustering group samples that belong to the same clustering group as the samples to be clustered in the pre-clustering group a number of times that reaches a second set value, based on the strong judgment matrix, to obtain the modified clustering group; The loop unit is used to remove the modified clustering group from the samples to be clustered and return to the selected unit until the number of the first values in each row of the weak judgment matrix corresponding to the remaining samples to be clustered is less than the third set value. All the modified clustering groups constitute the clustering result.
7. A computer-readable storage medium for clustering, characterized in that, It includes a memory for storing processor-executable instructions, which, when executed by the processor, implement the steps of the method according to any one of claims 1-5.
8. A device for clustering, characterized in that, It includes at least one processor and a memory storing computer-executable instructions, wherein the processor, when executing the instructions, implements the steps of the method according to any one of claims 1-5.
Citation Information
Patent Citations
Integrated classification identification method fused with classification and clustering
CN107563401A
Oil-well-parameter analysis combination algorithm based on k-means
CN108678728A
Network failure detection method and network failure detection system
US20090265784A1