Clustering method, device, computer equipment and storage medium
By using the distance clustering algorithm and iterative update method of target weights during the clustering process, the problem of information loss in high-dimensional data clustering is solved, and the accuracy and efficiency of clustering results are improved.
Patent Information
- Application Number
- CN202410078590.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-19
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2044-01-19
AI Technical Summary
In the clustering process of high-dimensional data, the prior art causes information loss through feature dimensionality reduction, thereby reducing the accuracy of clustering results.
Through iterative updates of distance clustering algorithm and target weights, the weighted distance between samples is dynamically adjusted to avoid data compression and retain complete data information.
It improves the accuracy and reliability of clustering results, adapts to the dynamically changing clustering process, and improves clustering efficiency.
Smart Images

Figure CN118094273B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a clustering method, apparatus, computer equipment, storage medium and computer program product. Background Art
[0002] In actual application scenarios, more comprehensive and integrated information can be mined from the multimodal data of the target object, integrating multiple data sources such as clinical manifestations, biochemical indicators, and imaging examinations, revealing the complex interactions between different features, and discovering the similarities and differences between different target objects, thereby providing early warnings. However, in the clinical diagnosis and treatment of target objects, high-dimensional data is often faced, including structured data such as test indicators, text data, image data and other multimodal data, all of which contain a large number of features. Therefore, when clustering high-dimensional data, it needs to be processed.
[0003] In related technologies, feature dimensionality reduction is generally performed, such as using principal component analysis to calculate the covariance matrix between data, and performing eigenvalue decomposition on it to obtain principal components (eigenvectors) to represent the data. However, compressing all high-dimensional spatial information into a limited low-dimensional representation space will lose some information, resulting in poor accuracy of clustering results. Summary of the invention
[0004] Based on this, it is necessary to provide a clustering method, device, computer equipment, computer-readable storage medium and computer program product that can retain complete data information and improve the accuracy of clustering results in response to the above technical problems.
[0005] In a first aspect, the present application provides a clustering method. The method comprises:
[0006] Obtaining a plurality of samples included in the data to be clustered and a target weight of each of the samples;
[0007] Clustering the multiple samples by using a distance clustering algorithm and a target weight of each of the samples to obtain a first clustering result, wherein the first clustering result includes multiple clusters;
[0008] Determining a discrimination parameter corresponding to the first clustering result, and determining a linear discriminant parameter corresponding to each of the clusters;
[0009] The target weight of each sample is updated based on the linear discriminant parameter corresponding to each cluster to obtain an updated target weight, and based on the updated target weight, the step of clustering the multiple samples by using the distance clustering algorithm and the target weight of each sample is re-executed until the discrimination parameter and the linear discriminant parameter meet the preset clustering completion condition, and the first clustering result is used as the target clustering result.
[0010] In one embodiment, clustering the plurality of samples by using a distance clustering algorithm and a target weight of each of the samples to obtain a first clustering result includes:
[0011] Calculate the initial distance between each sample through the distance clustering algorithm;
[0012] Calculating a weighted distance between each sample based on an initial distance between each sample and a target weight of each sample;
[0013] The samples are divided into a plurality of clusters based on the weighted distances between the samples to obtain a first clustering result.
[0014] In one embodiment, determining the distinguishing parameter corresponding to the first clustering result includes:
[0015] For the first cluster of the first clustering result, respectively calculate the inter-class similarities between the first cluster and other clusters, and determine the maximum inter-class similarity;
[0016] A mean calculation is performed based on the maximum inter-class similarities corresponding to each cluster and the number of clusters included in the first clustering to obtain a distinction parameter corresponding to the first clustering result.
[0017] In one embodiment, respectively calculating the inter-class similarities between the first cluster and other clusters and determining the maximum inter-class similarity includes:
[0018] For each target cluster in the other clusters, calculating the center point distance between the center point of the target cluster and the center point of the first cluster, and calculating the first cluster intra-cluster average distance of the first cluster and the second cluster intra-cluster average distance of the target cluster, and calculating the inter-class similarity between the first cluster and the target cluster based on the center point distance, the first cluster intra-cluster average distance and the second cluster intra-cluster average distance;
[0019] Among the inter-class similarities between the first cluster and each of the other target clusters, determine the inter-class similarity with the largest value.
[0020] In one embodiment, determining the linear discriminant parameters corresponding to each of the clusters includes:
[0021] For each cluster included in the first clustering result, the feature inter-class variance and the feature intra-class variance of the cluster are calculated; and based on the ratio of the feature inter-class variance to the feature intra-class variance, a linear discriminant parameter of the cluster is determined.
[0022] In one embodiment, the updating of the target weight of each sample based on the linear discriminant parameter corresponding to each cluster to obtain the updated target weight includes:
[0023] Calculating the mean of the linear discriminant parameter of each cluster, and determining the standard deviation of the linear discriminant parameter corresponding to the cluster based on the linear discriminant parameter of the cluster and the mean of the linear discriminant parameter;
[0024] Based on the target weight of the sample, a preset learning rate factor and a standard deviation of a linear discriminant parameter of a cluster where the sample is located, an updated target weight of the sample is obtained.
[0025] In one embodiment, the method further comprises:
[0026] Generate a feature weight sequence based on the weights of the samples corresponding to the clusters included in the target clustering result and the features corresponding to the samples;
[0027] In the weight sequence of the features, the features corresponding to the previous target number of weights are taken as the target feature set, and the weight sequence is arranged in order from large to small.
[0028] In a second aspect, the present application also provides a clustering device. The device comprises:
[0029] A first acquisition module is used to acquire a plurality of samples included in the data to be clustered and a target weight of each of the samples;
[0030] A clustering module, configured to cluster the plurality of samples by using a distance clustering algorithm and a target weight of each of the samples to obtain a first clustering result, wherein the first clustering result includes a plurality of clusters;
[0031] A first determination module, used to determine a distinction parameter corresponding to the first clustering result, and to determine a linear discriminant parameter corresponding to each of the clusters;
[0032] An updating module is used to update the target weight of each sample based on the linear discriminant parameter corresponding to each cluster, obtain an updated target weight, and re-execute the step of clustering the multiple samples by using the distance clustering algorithm and the target weight of each sample based on the updated target weight, until the discrimination parameter and the linear discriminant parameter meet the preset clustering completion condition, and take the first clustering result as the target clustering result.
[0033] In one embodiment, the clustering module is specifically used for:
[0034] Calculate the initial distance between each sample through the distance clustering algorithm;
[0035] Calculating a weighted distance between each sample based on an initial distance between each sample and a target weight of each sample;
[0036] The samples are divided into a plurality of clusters based on the weighted distances between the samples to obtain a first clustering result.
[0037] In one embodiment, the first determining module is specifically configured to:
[0038] For the first cluster of the first clustering result, respectively calculate the inter-class similarities between the first cluster and other clusters, and determine the maximum inter-class similarity;
[0039] A mean calculation is performed based on the maximum inter-class similarities corresponding to each cluster and the number of clusters included in the first clustering to obtain a distinction parameter corresponding to the first clustering result.
[0040] In one embodiment, the first determining module is further specifically configured to:
[0041] For each target cluster in the other clusters, calculating the center point distance between the center point of the target cluster and the center point of the first cluster, and calculating the first cluster intra-cluster average distance of the first cluster and the second cluster intra-cluster average distance of the target cluster, and calculating the inter-class similarity between the first cluster and the target cluster based on the center point distance, the first cluster intra-cluster average distance and the second cluster intra-cluster average distance;
[0042] Among the inter-class similarities between the first cluster and each of the other target clusters, determine the inter-class similarity with the largest value.
[0043] In one embodiment, the first determination module is specifically used to: calculate the feature inter-class variance and feature intra-class variance of each cluster included in the first clustering result; and determine the linear discriminant parameter of the cluster based on the ratio of the feature inter-class variance to the feature intra-class variance.
[0044] In one embodiment, the update module is specifically used to:
[0045] Calculating the mean of the linear discriminant parameter of each cluster, and determining the standard deviation of the linear discriminant parameter corresponding to the cluster based on the linear discriminant parameter of the cluster and the mean of the linear discriminant parameter;
[0046] Based on the target weight of the sample, a preset learning rate factor and a standard deviation of a linear discriminant parameter of a cluster where the sample is located, an updated target weight of the sample is obtained.
[0047] In one embodiment, the device further comprises:
[0048] A generating module, configured to generate a feature weight sequence based on the weights of the samples corresponding to the clusters included in the target clustering result and the features corresponding to the samples;
[0049] The arrangement module is used to take the features corresponding to the previous target number of weights as the target feature set in the weight sequence of the features, and the weight sequence is arranged in order from large to small.
[0050] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0051] Obtaining a plurality of samples included in the data to be clustered and a target weight of each of the samples;
[0052] Clustering the multiple samples by using a distance clustering algorithm and a target weight of each of the samples to obtain a first clustering result, wherein the first clustering result includes multiple clusters;
[0053] Determining a discrimination parameter corresponding to the first clustering result, and determining a linear discriminant parameter corresponding to each of the clusters;
[0054] The target weight of each sample is updated based on the linear discriminant parameter corresponding to each cluster to obtain an updated target weight, and based on the updated target weight, the step of clustering the multiple samples by using the distance clustering algorithm and the target weight of each sample is re-executed until the discrimination parameter and the linear discriminant parameter meet the preset clustering completion condition, and the first clustering result is used as the target clustering result.
[0055] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0056] Obtaining a plurality of samples included in the data to be clustered and a target weight of each of the samples;
[0057] Clustering the multiple samples by using a distance clustering algorithm and a target weight of each of the samples to obtain a first clustering result, wherein the first clustering result includes multiple clusters;
[0058] Determining a discrimination parameter corresponding to the first clustering result, and determining a linear discriminant parameter corresponding to each of the clusters;
[0059] The target weight of each sample is updated based on the linear discriminant parameter corresponding to each cluster to obtain an updated target weight, and based on the updated target weight, the step of clustering the multiple samples by using the distance clustering algorithm and the target weight of each sample is re-executed until the discrimination parameter and the linear discriminant parameter meet the preset clustering completion condition, and the first clustering result is used as the target clustering result.
[0060] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0061] Obtaining a plurality of samples included in the data to be clustered and a target weight of each of the samples;
[0062] Clustering the multiple samples by using a distance clustering algorithm and a target weight of each of the samples to obtain a first clustering result, wherein the first clustering result includes multiple clusters;
[0063] Determining a discrimination parameter corresponding to the first clustering result, and determining a linear discriminant parameter corresponding to each of the clusters;
[0064] The target weight of each sample is updated based on the linear discriminant parameter corresponding to each cluster to obtain an updated target weight, and based on the updated target weight, the step of clustering the multiple samples by using the distance clustering algorithm and the target weight of each sample is re-executed until the discrimination parameter and the linear discriminant parameter meet the preset clustering completion condition, and the first clustering result is used as the target clustering result.
[0065] The above clustering method, device, computer equipment, storage medium and computer program product, wherein the method comprises: obtaining multiple samples included in the data to be clustered and the target weight of each sample; clustering the multiple samples by using the distance clustering algorithm and the target weight of each sample to obtain a first clustering result, the first clustering result including multiple clusters; determining the distinguishing parameter corresponding to the first clustering result, and determining the linear discriminant parameter corresponding to each cluster; updating the target weight of each sample based on the linear discriminant parameter corresponding to each cluster to obtain the updated target weight, and re-executing the step of clustering the multiple samples by using the distance clustering algorithm and the target weight of each sample based on the updated target weight, until the distinguishing parameter and the linear discriminant parameter meet the preset clustering completion condition, and taking the first clustering result as the target clustering result. By adopting this method, data compression can be avoided, the complete information of the data is retained, the data clustering is realized by weighted distance and real-time updated weight, the reliability of clustering is improved, and the weight of the sample is updated in real time by dynamic iteration, which can better adapt to the dynamically changing clustering process and improve the clustering efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 A diagram of an application environment of a clustering method in one embodiment;
[0067] Figure 2 is a schematic diagram of a clustering method in one embodiment;
[0068] Figure 3 is a schematic diagram of a clustering method in one embodiment;
[0069] Figure 4 is a schematic diagram of a clustering method in one embodiment;
[0070] Figure 5 is a schematic diagram of a clustering method in one embodiment;
[0071] Figure 6 is a schematic diagram of a clustering method in one embodiment;
[0072] Figure 7 is a structural block diagram of a clustering device in one embodiment;
[0073] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0074] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0075] The present application embodiment provides a clustering method. The present embodiment uses the method applied to a terminal as an example. It is understandable that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. The above-mentioned terminals can be, but are not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server can be implemented with an independent server or a server cluster consisting of multiple servers. In this embodiment, if Figure 1 As shown, the clustering method includes the following steps:
[0076] Step 102: Obtain multiple samples included in the data to be clustered and the target weight of each sample.
[0077] Among them, the multiple samples included in the data to be clustered can be diagnosis and treatment data in medical scenarios, and can be multimodal data, such as structured data such as verification indicator data, text data, and image data, etc.; each sample can be a piece of data, such as verification indicator data of a target object, etc.; the target weight of the sample can include an initial weight pre-configured for the sample data, or a target weight obtained after updating the initial weight of the sample, or a target weight after updating the updated target weight. The target weight can be a weight factor, which can characterize the importance of the features represented by different samples, etc.
[0078] Specifically, in a clustering scenario, the terminal may obtain data to be clustered including multiple samples, and determine target weights corresponding to respective samples.
[0079] In one example, the process of obtaining the data to be clustered can also be: the terminal can obtain the initial data to be clustered, and perform data cleaning on the obtained initial data to be clustered to obtain the cleaned initial data to be clustered (hereinafter referred to as the first data to be clustered), and standardize the first data to be clustered to obtain the standardized first data to be clustered, that is, the second data to be clustered; the terminal can also screen multiple samples contained in the second data to be clustered, eliminate samples containing missing attributes or erroneous attributes, and obtain the target data to be clustered, that is, the data to be clustered.
[0080] Step 104 , clustering the multiple samples by using a distance clustering algorithm and a target weight of each sample to obtain a first clustering result.
[0081] The first clustering result includes multiple clusters, the distance clustering algorithm may be an algorithm for clustering based on distance, for example, it may be K-Medoids clustering; the multiple clusters included in the first clustering result may be multiple cluster clusters.
[0082] Specifically, the terminal can calculate the initial distance between each sample contained in the data to be clustered through a distance clustering algorithm, and adjust the initial distance between each sample based on the target weight of each sample to obtain a weighted distance; in this way, the terminal can divide each sample based on the obtained weighted distance between each sample to obtain a first clustering result containing multiple cluster clusters.
[0083] In one example, the initial distance between each sample includes the initial distance between each sample contained in the data to be clustered and each other sample; for example, the data to be clustered includes a first sample, a second sample, a third sample and a fourth sample, then for each sample, for example, it may be the first sample, the initial distance corresponding to the first sample includes the distance between the first sample and the second sample, the distance between the first sample and the third sample, and the distance between the first sample and the fourth sample. The initial distance of the second sample is similar to the initial distance of the first sample, which will not be repeated here.
[0084] Step 106: determining a discrimination parameter corresponding to the first clustering result, and determining a linear discriminant parameter corresponding to each cluster.
[0085] Among them, the distinguishing parameter can be a parameter for quantifying the clustering results, for example, it can be a DBI parameter (Davies-Bouldin Index), which is used to measure the closeness and separation between the multiple clusters contained in the clustering results; the DBI parameter can be the ratio of the intra-class distance to the inter-class distance of all clusters (intra-class / inter-class). If the inter-class distance is larger and the intra-class distance is smaller, the data in the cluster is more concentrated, that is, the cluster is closer. The linear discriminant parameter corresponding to each cluster can be the FDR index (Fisher's Discriminant Ratio), which is the ratio of the between-class variance to the intra-class variance, and is used to measure the separation between different categories in the classification problem.
[0086] Specifically, after the terminal obtains the first clustering result, the terminal can obtain the distinction parameters corresponding to the first clustering result based on the number of multiple clusters obtained in the first clustering result and the maximum inter-class similarity corresponding to each cluster, and calculate based on the feature inter-class variance and feature intra-class variance corresponding to each cluster to obtain the linear discriminant parameters corresponding to each cluster.
[0087] Step 108, based on the linear discriminant parameters corresponding to each cluster, the target weight of each sample is updated to obtain an updated target weight, and based on the updated target weight, the step of clustering multiple samples by using the distance clustering algorithm and the target weights of each sample is re-executed until the discrimination parameters and the linear discriminant parameters meet the preset clustering completion conditions, and the first clustering result is used as the target clustering result.
[0088] The preset clustering completion condition may be that the distinguishing parameter matches the preset distinguishing parameter threshold, and the linear discriminant parameter satisfies the preset optimization condition; in one example, the preset clustering completion condition may be that the distinguishing parameter (DBI) is less than the preset distinguishing parameter threshold, and the linear discriminant parameter has converged. When the terminal determines that the current linear discriminant parameter has converged and the current distinguishing parameter is less than the preset distinguishing parameter threshold, the terminal may determine that the preset clustering completion condition is currently satisfied. Optionally, the preset distinguishing parameter threshold may be 0.
[0089] Specifically, the terminal can update the target weight of each sample based on the determined linear discriminant parameters corresponding to each cluster, and obtain an updated target weight; in this way, the terminal can re-execute the step of clustering multiple samples based on the distance clustering algorithm and the target weights of each sample to obtain a first clustering result based on the updated target weight, and recalculate the distinguishing parameters corresponding to the first clustering result, and the linear discriminant parameters corresponding to the multiple clusters included in the first clustering result; the terminal can determine whether the distinguishing parameters corresponding to the current first clustering result, and the linear discriminant parameters corresponding to the multiple clusters included in the first clustering result meet the preset clustering completion conditions. If the current distinguishing parameters and linear discriminant parameters meet the preset clustering completion conditions, the terminal can determine the current first clustering result as the final target clustering result;
[0090] If the current distinction parameters and linear discriminant parameters do not meet the preset clustering completion conditions, the terminal can update the target weight of each sample based on the linear discriminant parameters corresponding to the current clusters, obtain the updated target weight, and re-execute the step of clustering multiple samples based on the distance clustering algorithm and the target weights of each sample based on the updated target weight, until the distinction parameters and linear discriminant parameters meet the preset clustering completion conditions, and obtain the final target clustering result.
[0091] In the above clustering method, multiple samples included in the data to be clustered and the target weight of each sample are obtained. Multiple samples are clustered by the distance clustering algorithm and the target weight of each sample to obtain a first clustering result, which includes multiple clusters. The distinguishing parameters corresponding to the first clustering result are determined, and the linear discriminant parameters corresponding to each cluster are determined. The target weight of each sample is updated based on the linear discriminant parameters corresponding to each cluster to obtain the updated target weight, and based on the updated target weight, the step of clustering multiple samples by the distance clustering algorithm and the target weight of each sample is re-executed until the distinguishing parameters and the linear discriminant parameters meet the preset clustering completion conditions, and the first clustering result is used as the target clustering result. By adopting this method, data compression can be avoided, the complete information of the data is retained, and the data is clustered by weighted distance and real-time updated weights, which improves the reliability of clustering. The weight of the sample is updated in real time by dynamic iteration, which can better adapt to the dynamically changing clustering process and improve the clustering efficiency.
[0092] In one embodiment, Figure 2 As shown, the specific processing process of the step "clustering multiple samples by using the distance clustering algorithm and the target weight of each sample to obtain the first clustering result" includes:
[0093] Step 202: Calculate the initial distance between each sample using a distance clustering algorithm.
[0094] The clustering algorithm may be K-Medoids clustering, and the initial distance between each sample may be Minkowski distance.
[0095] Specifically, the terminal can use the distance clustering algorithm to calculate the initial distances corresponding to each sample contained in the data to be clustered. That is, for each sample contained in the data to be clustered, the terminal can use the clustering distance algorithm to calculate the distance between the sample and all other samples. Based on this, the terminal can obtain the initial distances between each sample contained in the data to be clustered and each other sample.
[0096] Step 204 , based on the initial distance between each sample and the target weight of each sample, calculate the weighted distance between each sample.
[0097] The weighted distance may be a distance obtained by weighting the initial distances between the samples based on the target weights of the samples.
[0098] Specifically, the terminal can perform weighted processing based on the target weight of each sample and the calculated initial distance between each sample to obtain the weighted distance between each sample; for each sample included in the data to be clustered, the terminal can adjust the initial distance between the sample and each other sample based on the target weight corresponding to the sample to obtain the weighted distance between the sample and each other sample.
[0099] In one example, the process of adjusting the initial distance based on weight may include: for each sample included in the data to be clustered, the terminal adjusts the initial distance between the sample and other samples respectively. For example, based on the target weight corresponding to the sample and the target weights corresponding to other samples, the initial distance between the sample and other samples is adjusted to obtain a weighted distance.
[0100] Step 206: divide each sample into multiple clusters based on the weighted distance between each sample to obtain a first clustering result.
[0101] Specifically, the terminal can cluster each sample based on the weighted distance between each sample, and classify the samples whose distance is less than a preset distance threshold into the same cluster, so as to obtain an initial clustering result including multiple clusters. In one example, for a first sample, the terminal can determine the minimum weighted distance based on the weighted distance between the first sample and other samples, and classify the sample corresponding to the weighted distance with the minimum value into the same cluster as the first sample, and execute the process of the above embodiment for each sample included in the data to be clustered, so as to obtain a first clustering result including multiple clusters.
[0102] In this embodiment, a weight factor is introduced based on the cluster distance to distinguish the importance of each sample and ensure the flexibility of clustering.
[0103] In one embodiment, Figure 3 As shown, the specific processing process of the step "determining the distinguishing parameter corresponding to the first clustering result" includes:
[0104] Step 302: for the first cluster of the first clustering result, respectively calculate the inter-class similarities between the first cluster and other clusters, and determine the maximum inter-class similarity.
[0105] Among them, the distinguishing parameter represents the ratio between the sum of the intra-class distances and the out-of-class distances; the inter-class similarity between the first cluster and other clusters can be obtained based on the average intra-cluster distance of the first cluster, the average intra-cluster distances of other clusters, and the distance between the first cluster and other clusters. The average intra-cluster distance represents the degree of dispersion between data points in the same cluster, and the distance between the first cluster and other clusters represents; the distance between classes can specifically be the distance between the center point of the first cluster and the center point of other clusters; the inter-class similarity is the ratio of the sum of the dispersion degree to the inter-class distance.
[0106] Specifically, the terminal can calculate the maximum inter-class similarity corresponding to each cluster included in the first clustering result. For each cluster (for the sake of ease of description, each cluster is referred to as each first cluster), the terminal can respectively calculate the inter-class similarity between the first cluster and other clusters, and filter out the inter-class similarity with the largest value.
[0107] Step 304 , performing mean calculation based on the maximum inter-class similarities corresponding to each cluster and the number of clusters included in the first clustering, to obtain a distinction parameter corresponding to the first clustering result.
[0108] Specifically, the terminal can determine the number of clusters contained in the first clustering result, and perform mean calculation based on the number of clusters and the maximum inter-class similarities corresponding to each first cluster, to obtain the distinguishing parameter corresponding to the first clustering result; in one example, the terminal can calculate the sum of the maximum inter-class similarities corresponding to each first cluster, and calculate the ratio between the sum and the number of clusters, and determine the ratio as the distinguishing parameter corresponding to the first clustering result.
[0109] In this embodiment, the inter-class similarity between each cluster and other clusters is obtained by the sum of the dispersion degrees and the inter-class distance, and the distinguishing parameters of the clustering results are calculated based on the maximum inter-class similarity corresponding to each cluster. The ratio of the inter-class distance to the intra-class distance can be calculated to optimize the number of clusters in the clustering, providing a reliable data basis for subsequent clustering.
[0110] In one embodiment, Figure 4 As shown, the specific processing process of the step of "respectively calculating the inter-class similarities between the first cluster and other clusters, and determining the maximum inter-class similarity" includes:
[0111] Step 402, for each target cluster in other clusters, calculate the center point distance between the center point of the target cluster and the center point of the first cluster, and calculate the first cluster average distance and the second cluster average distance of the target cluster, and calculate the inter-class similarity between the first cluster and the target cluster based on the center point distance, the first cluster average distance and the second cluster average distance.
[0112] The center point distance between the center point of the target cluster and the center point of the first cluster may be the Euclidean distance between the two center points; and the average distance within the cluster may represent the mean of the Euclidean distances between the samples within the cluster.
[0113] Specifically, the terminal can respectively calculate the inter-class similarity between the first cluster and other clusters (for ease of description, hereinafter referred to as the target cluster), and for each other cluster, the terminal can calculate the center point distance between the center point of the other cluster and the center point of the first cluster; the terminal can calculate the average intra-cluster distance of the first cluster and the average intra-cluster distance of the target cluster, and calculate the sum of the first cluster average distance and the second cluster average distance of the target cluster. In this way, the terminal can calculate the ratio between the sum and the center point distance, and use the ratio to determine the inter-class similarity between the first cluster and other clusters (target clusters).
[0114] Step 404 , among the inter-class similarities between the first cluster and other target clusters, determine the inter-class similarity with the largest value.
[0115] Specifically, based on the process described in the above embodiment, the terminal can obtain the inter-class similarities corresponding to the first cluster and other target clusters respectively, and the terminal can perform screening based on the numerical values to extract the inter-class similarity with the largest numerical value.
[0116] In this embodiment, the inter-class similarity between each cluster and other clusters is obtained by the sum of the dispersion degree and the inter-class distance, and based on the maximum inter-class similarity corresponding to each cluster, the distribution degree of data points within and between clusters and the similarity between clusters can be comprehensively analyzed, providing a reliable data basis for subsequent clustering.
[0117] In one embodiment, the specific processing of the step of "determining the linear discriminant parameters corresponding to each cluster" includes:
[0118] For each cluster included in the first clustering result, the feature inter-class variance and feature intra-class variance of the cluster are calculated. Based on the ratio of the feature inter-class variance to the feature intra-class variance, the linear discriminant parameter of the cluster is determined.
[0119] The linear discriminant parameter may be Fisher's Discriminant Ratio corresponding to the cluster.
[0120] Specifically, for each cluster included in the first clustering result, the terminal may calculate the feature inter-class variance and the feature intra-class variance within the cluster, and calculate the ratio between the feature inter-class variance and the feature intra-class variance, and determine the ratio as the linear discriminant parameter of the cluster.
[0121] In this embodiment, the separation degree between different categories can be quantified to improve the accuracy of clustering results.
[0122] In one embodiment, Figure 5 As shown, the specific processing process of the step "updating the target weight of each sample based on the linear discriminant parameters corresponding to each cluster to obtain the updated target weight" includes:
[0123] Step 502, calculating the mean of the linear discriminant parameter of each cluster, and for each cluster, determining the standard deviation of the linear discriminant parameter corresponding to the cluster based on the mean of the linear discriminant parameter and the linear discriminant parameter corresponding to the cluster.
[0124] Specifically, the terminal can calculate the mean of the linear discriminant parameters based on the linear discriminant parameters corresponding to each cluster, for example, the sum of the linear discriminant parameters corresponding to each cluster can be calculated, and the ratio of the sum of the linear discriminant parameters to the number of clusters can be calculated, and the ratio can be determined as the mean of the linear discriminant parameters of each cluster; based on this, for each cluster, the terminal can calculate the difference between the linear discriminant parameter corresponding to the cluster and the mean of the linear discriminant parameters, and determine the difference as the standard deviation of the linear discriminant parameter corresponding to the cluster.
[0125] Step 504 , for each sample in each cluster, based on the target weight of the sample, a preset learning rate factor and the standard deviation of the linear discriminant parameter of the cluster where the sample is located, obtain an updated target weight of the sample.
[0126] The preset learning rate factor may be a preconfigured learning rate, for example, any value from 0 to 1, which is used to control the update step size.
[0127] Specifically, for each sample in each cluster, the terminal can calculate the product of the preset learning rate factor and the standard deviation of the linear discriminant parameter of the cluster where the sample is located, and obtain the updated target weight corresponding to the target sample based on the sum of the target weight corresponding to the sample and the product value.
[0128] In this embodiment, by dynamically updating the weights, the dynamically changing clustering exploration process can be flexibly adapted through dynamic iteration, thereby improving the efficiency of finding a better clustering result, ensuring the accuracy of clustering and improving clustering efficiency.
[0129] In one embodiment, Figure 6 As shown, the clustering method also includes:
[0130] Step 602: Generate a feature weight sequence based on the weights of samples corresponding to each cluster included in the target clustering result and the features corresponding to each sample.
[0131] Step 604: In the feature weight sequence, the features corresponding to the first target number of weights are used as the target feature set.
[0132] Among them, the weight sequence is arranged in order from large to small.
[0133] Specifically, the terminal can perform weighted calculation based on the weights of the samples corresponding to each cluster contained in the target clustering result, and the features corresponding to each sample, to obtain the target weights corresponding to each feature, and arrange the target weights of each feature in descending order to obtain a feature sequence, extract the first target number of features, and obtain a target feature set. In other words, the terminal can select the weight array recorded in the final clustering result, and select the first m features with the highest weights as the final selected feature set.
[0134] In this embodiment, the sample sparseness problem of clustering high-dimensional data and the inaccurate results of manual feature selection can be avoided, and the clustering efficiency and clustering accuracy can be improved on the basis of ensuring comprehensive clustering.
[0135] The specific implementation process of the above clustering method is described below in conjunction with a detailed embodiment:
[0136] Step S1, performing data cleaning and standardization processing on the acquired data.
[0137] Step S2, screening and removing samples with missing or erroneous attributes to obtain data for clustering.
[0138] Step S3, selecting a distance-based clustering algorithm, such as K-Medoids clustering.
[0139] Step S3.1, define the clustering metric - Weighted Minkowski Distance, denoted as d. Based on the Minkowski distance, a weight factor λ is introduced to measure the similarity or difference between samples and process data with different attribute importance. Initialize the weight λ of all samples to 1.
[0140] Step S3.2, define the objective function - select the quantitative index of clustering results FDR index (Fisher's Discriminant Ratio) as the objective function. FDR (linear discriminant parameter) is the ratio of between-class variance to within-class variance, which is used to measure the degree of separation between different categories in classification problems:
[0141] FDR=S B / S W .
[0142] Among them, S B is the feature class variance, S W is the intra-class variance of the feature.
[0143] Step S3.3, define the weight vector update strategy to update the weight factor λ, use the FDR index in step S3.2, calculate the inter-cluster FDR mean, and further calculate the FDR standard deviation. If the value range of an attribute between different clusters is large (large standard deviation), it will get a higher weight:
[0144]
[0145] in, is the mean FDR between classes, FDR i is the FDR index of the ith cluster, is the standard deviation of the FDR for cluster i. Based on the calculated standard deviation, update the weight factor:
[0146]
[0147] Among them, α is the learning rate that controls the update step size, is the weight of the i-th feature at the t-th iteration.
[0148] Step S4, performing clustering iteration.
[0149] Step 1: perform distance-based clustering based on weighted Minkowski distance.
[0150] Step 2, obtain the clustering results, and use the FDR index to calculate the clustering discrimination. At the same time, calculate the DBI index (Davies-Bouldin Index) of the quantitative clustering results. The DBI index of the clustering results is the discrimination between the subtypes obtained by clustering. Record the DBI index and FDR index of the iterative results. The DBI index of the clustering results is the discrimination between the subtypes obtained by clustering, which is used to measure the compactness and separation of clustering:
[0151]
[0152] Among them, K is the number of clusters, C i is the average distance within the i-th cluster, C j is the average intra-cluster distance of the jth cluster, d cen is the distance between cluster centers.
[0153] Step 3: Update the target weights corresponding to each sample based on the weight vector update strategy to obtain the updated target weights.
[0154] Step 4: Use the updated target weights and re-execute steps 1-3.
[0155] Step 5: After a certain number of iterations, visualize the curves of the FDR index and DBI index recorded during the iteration process as they change with the number of iterations, select an iteration process with better FDR index and DBI index, that is, the first clustering result corresponding to the discrimination parameters and linear discriminant parameters that meet the preset clustering completion conditions as the final target clustering result, and based on the weight array recorded in the target clustering result, select the top m features with the highest weights as the final selected feature set.
[0156] The clustering method provided in the present application can be a clustering algorithm based on the EM idea for feature selection, which can solve the problem of sample sparsity and biased results of manual feature selection for clustering of current high-dimensional data. Specifically, by using the EM algorithm to effectively perform automated feature selection, it is possible to find clustering results with a high degree of compactness, thereby improving the reliability of clustering feature selection. Clustering is completed by weighted distance calculation, with little change to the traditional clustering algorithm. This method can be applied to distance-based clustering algorithms, has strong scalability, and is based on a weight update function. It uses a dynamic iteration method to flexibly adapt to the dynamically changing clustering exploration process, thereby improving the efficiency of finding a better solution.
[0157] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0158] Based on the same inventive concept, the embodiment of the present application also provides a clustering device for implementing the clustering method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more clustering device embodiments provided below can refer to the limitations on the clustering method above, and will not be repeated here.
[0159] In one embodiment, Figure 7 As shown, a clustering device 700 is provided, comprising:
[0160] A first acquisition module 702 is used to acquire multiple samples included in the data to be clustered and a target weight of each sample;
[0161] A clustering module 704 is used to cluster the multiple samples by using a distance clustering algorithm and a target weight of each sample to obtain a first clustering result, where the first clustering result includes multiple clusters;
[0162] A first determination module 706 is used to determine the discrimination parameter corresponding to the first clustering result, and to determine the linear discriminant parameter corresponding to each cluster;
[0163] The updating module 708 is used to update the target weight of each sample based on the linear discriminant parameters corresponding to each cluster, obtain the updated target weight, and re-execute the step of clustering multiple samples through the distance clustering algorithm and the target weights of each sample based on the updated target weight, until the distinguishing parameters and the linear discriminant parameters meet the preset clustering completion conditions, and take the first clustering result as the target clustering result.
[0164] In one embodiment, the clustering module is specifically used to:
[0165] Calculate the initial distance between each sample through the distance clustering algorithm;
[0166] Based on the initial distance between each sample and the target weight of each sample, the weighted distance between each sample is calculated;
[0167] Each sample is divided into multiple clusters based on the weighted distance between each sample to obtain a first clustering result.
[0168] In one embodiment, the first determining module is specifically used to:
[0169] For the first cluster of the first clustering result, respectively calculate the inter-class similarities between the first cluster and other clusters, and determine the maximum inter-class similarity;
[0170] Based on the maximum inter-class similarities corresponding to each cluster and the number of clusters included in the first clustering, a mean calculation is performed to obtain a distinction parameter corresponding to the first clustering result.
[0171] In one embodiment, the first determining module is further specifically configured to:
[0172] For each target cluster in other clusters, the center point distance between the center point of the target cluster and the center point of the first cluster is calculated, and the first cluster average distance and the second cluster average distance of the target cluster are calculated, and the inter-class similarity between the first cluster and the target cluster is calculated based on the center point distance, the first cluster average distance and the second cluster average distance;
[0173] Among the inter-class similarities between the first cluster and other target clusters, determine the inter-class similarity with the largest value.
[0174] In one embodiment, the first determination module is specifically used to: calculate the feature inter-class variance and feature intra-class variance of each cluster included in the first clustering result; and determine the linear discriminant parameter of the cluster based on the ratio of the feature inter-class variance to the feature intra-class variance.
[0175] In one embodiment, the update module is specifically used to:
[0176] Calculate the mean of the linear discriminant parameter of each cluster, and determine the standard deviation of the linear discriminant parameter corresponding to the cluster based on the linear discriminant parameter of the cluster and the mean of the linear discriminant parameter;
[0177] Based on the target weight of the sample, the preset learning rate factor and the standard deviation of the linear discriminant parameter of the cluster where the sample is located, the updated target weight of the sample is obtained.
[0178] In one embodiment, the device further comprises:
[0179] A generation module, used for generating a feature weight sequence based on the weights of samples corresponding to each cluster contained in the target clustering result and the features corresponding to each sample;
[0180] The arrangement module is used to take the features corresponding to the previous target number of weights as the target feature set in the feature weight sequence, and the weight sequence is arranged in descending order.
[0181] Each module in the above clustering device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0182] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store clustering data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a clustering method is implemented.
[0183] Those skilled in the art will understand that Figure 8The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0184] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0185] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0186] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0187] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0188] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0189] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0190] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A clustering method, characterized in that: The method comprises: Acquire multiple samples included in the data to be clustered and a target weight of each of the samples, wherein the multiple samples included in the data to be clustered are diagnosis and treatment data in a medical scenario, the diagnosis and treatment data include multimodal data, the multimodal data include verification indicator data, text data, and image data, the verification indicator data is structured data, and the target weight represents the importance of the features represented by different samples; Clustering the multiple samples by using a distance clustering algorithm and a target weight of each of the samples to obtain a first clustering result, wherein the first clustering result includes multiple clusters; Determining a discrimination parameter corresponding to the first clustering result, and determining a linear discriminant parameter corresponding to each of the clusters; The target weight of each sample is updated based on the linear discriminant parameter corresponding to each cluster to obtain an updated target weight, and based on the updated target weight, the step of clustering the multiple samples by using the distance clustering algorithm and the target weight of each sample is re-executed until the discrimination parameter and the linear discriminant parameter meet the preset clustering completion condition, and the first clustering result is used as the target clustering result.
2. The method according to claim 1, characterized in that: The clustering of the plurality of samples by using a distance clustering algorithm and a target weight of each of the samples to obtain a first clustering result includes: Calculate the initial distance between each sample through the distance clustering algorithm; Calculating a weighted distance between each sample based on an initial distance between each sample and a target weight of each sample; The samples are divided into a plurality of clusters based on the weighted distances between the samples to obtain a first clustering result.
3. The method according to claim 1, characterized in that The determining of the distinguishing parameter corresponding to the first clustering result includes: For the first cluster of the first clustering result, respectively calculate the inter-class similarities between the first cluster and other clusters, and determine the maximum inter-class similarity; A mean calculation is performed based on the maximum inter-class similarities corresponding to each cluster and the number of clusters included in the first clustering to obtain a distinction parameter corresponding to the first clustering result.
4. The method according to claim 3, characterized in that The respectively calculating the inter-class similarities between the first cluster and other clusters and determining the maximum inter-class similarity includes: For each target cluster in the other clusters, calculating the center point distance between the center point of the target cluster and the center point of the first cluster, and calculating the first cluster intra-cluster average distance of the first cluster and the second cluster intra-cluster average distance of the target cluster, and calculating the inter-class similarity between the first cluster and the target cluster based on the center point distance, the first cluster intra-cluster average distance and the second cluster intra-cluster average distance; Among the inter-class similarities between the first cluster and each of the other target clusters, determine the inter-class similarity with the largest value.
5. The method according to claim 1, characterized in that The determining of the linear discriminant parameters corresponding to each of the clusters comprises: For each cluster included in the first clustering result, the feature inter-class variance and the feature intra-class variance of the cluster are calculated; and based on the ratio of the feature inter-class variance to the feature intra-class variance, a linear discriminant parameter of the cluster is determined.
6. The method according to claim 1, characterized in that The updating of the target weight of each sample based on the linear discriminant parameter corresponding to each cluster to obtain the updated target weight includes: Calculating the mean of the linear discriminant parameter of each of the clusters, and for each of the clusters, determining the standard deviation of the linear discriminant parameter corresponding to the cluster based on the mean of the linear discriminant parameter and the linear discriminant parameter of the cluster; For each sample in each cluster, an updated target weight of the sample is obtained based on the target weight of the sample, a preset learning rate factor and a standard deviation of a linear discriminant parameter of the cluster to which the sample belongs.
7. The method according to claim 1, characterized in that The method further comprises: Generate a feature weight sequence based on the weights of the samples corresponding to the clusters included in the target clustering result and the features corresponding to the samples; In the weight sequence of the features, the features corresponding to the previous target number of weights are taken as the target feature set, and the weight sequence is arranged in order from large to small.
8. A clustering device, characterized in that: The device comprises: A first acquisition module is used to acquire a plurality of samples included in the data to be clustered and a target weight of each of the samples, wherein the plurality of samples included in the data to be clustered are diagnosis and treatment data in a medical scenario, wherein the diagnosis and treatment data include multimodal data, wherein the multimodal data include verification index data, text data, and image data, wherein the verification index data is structured data, and the target weight represents the importance of the features represented by the different samples; A clustering module, configured to cluster the plurality of samples by using a distance clustering algorithm and a target weight of each of the samples to obtain a first clustering result, wherein the first clustering result includes a plurality of clusters; A first determination module, used to determine a distinction parameter corresponding to the first clustering result, and to determine a linear discriminant parameter corresponding to each of the clusters; An updating module is used to update the target weight of each sample based on the linear discriminant parameter corresponding to each cluster, obtain an updated target weight, and re-execute the step of clustering the multiple samples by using the distance clustering algorithm and the target weight of each sample based on the updated target weight, until the discrimination parameter and the linear discriminant parameter meet the preset clustering completion condition, and take the first clustering result as the target clustering result.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Clustering method and device
CN108805174A
Model training method and device, image classification method and device and storage medium
CN114092920A