ClusteringComponents

ClusteringComponents[array]

gives an array in which each element at the lowest level of array is replaced by an integer index representing the cluster in which the element lies.

ClusteringComponents[array,n]

finds n clusters.

ClusteringComponents[array,n,level]

finds clusters at the specified level in array.

ClusteringComponents[image]

finds clusters of pixels with similar values in image.

ClusteringComponents[image,n]

finds n clusters in image.

Details and Options

Examples

open allclose all

Basic Examples  (3)

Label two clusters of values in a list:

Label a vector of strings:

Cluster analysis of an MR image:

Scope  (10)

Clusters of values in a matrix:

Find color clusters in an image:

Find clusters in a 3D image:

Clustering transform of nested lists:

Find clusters at list level 2:

Find clusters at list level 1:

Find duplicates by specifying a large number of clusters:

Labeling clusters in a matrix:

Clustering lists of Booleans:

Clustering a list of Boolean vectors:

Options  (13)

CriterionFunction  (1)

Generate some separated data and visualize it:

Find a cluster assignment with exactly two clusters using different settings for CriterionFunction:

Compare the two clusterings of the data:

DistanceFunction  (1)

By default, EditDistance is used to cluster a list of strings:

Use HammingDistance to cluster based on the number of characters that disagree:

FeatureExtractor  (1)

Find clustering components for a list of images:

Create a custom FeatureExtractor to extract features:

Look at the resulting features:

Use the FeatureExtractor to find new clustering components:

Look at the new clustering:

FeatureNames  (1)

Use FeatureNames to name features, and refer to their names in further specifications:

FeatureTypes  (1)

Use FeatureTypes to enforce the interpretation of the features:

Compare it to the result obtained by assuming nominal features:

Method  (5)

Generate normally distributed data and visualize its histogram:

Find cluster assignments for this data using the "GaussianMixture" method:

Visualize the corresponding clustering:

Find cluster assignments for a list of string using the k-medoids method:

Look at the resulting clustering:

Find color clusters in an image using different methods:

Find color clusters in an image using the "NeighborhoodContraction" method and its suboption:

Find color clusters in an image using the "Spectral" method and its suboption:

PerformanceGoal  (1)

Generate 500 random numerical vectors of length 1000:

Compute their clustering and benchmark the operation:

Perform the same operation with PerformanceGoal set to "Quality":

RandomSeeding  (1)

Generate 500 random numerical vectors in 2 dimensions:

Compute their clustering several times and compare the results:

Compute their clustering several times by changing the RandomSeeding option and compare the results:

Weights  (1)

Obtain cluster assignment for some numerical data:

Look at the cluster assignment when changing the weight given to each number:

Applications  (2)

Color segmentation of a microscopic image, after smoothing with a PeronaMalik filter:

Binary segmentation of an image:

Properties & Relations  (3)

ClusteringComponents gives an array of cluster indices while FindClusters returns the list of clusters:

Convert the result of ClusteringComponents to partitions of similar elements:

FindClusters yields the same result:

Convert the result of FindClusters to a list of cluster indices:

ClusteringComponents yields the same result:

Possible Issues  (1)

The "KMeans" method cannot be used when the mean of a subset of the input does not belong to the input space:

Wolfram Research (2010), ClusteringComponents, Wolfram Language function, https://reference.wolfram.com/language/ref/ClusteringComponents.html (updated 2022).

Text

Wolfram Research (2010), ClusteringComponents, Wolfram Language function, https://reference.wolfram.com/language/ref/ClusteringComponents.html (updated 2022).

CMS

Wolfram Language. 2010. "ClusteringComponents." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/ClusteringComponents.html.

APA

Wolfram Language. (2010). ClusteringComponents. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ClusteringComponents.html

BibTeX

@misc{reference.wolfram_2024_clusteringcomponents, author="Wolfram Research", title="{ClusteringComponents}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/ClusteringComponents.html}", note=[Accessed: 28-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_clusteringcomponents, organization={Wolfram Research}, title={ClusteringComponents}, year={2022}, url={https://reference.wolfram.com/language/ref/ClusteringComponents.html}, note=[Accessed: 28-November-2024 ]}