Main Content


Class: clustering.evaluation.ClusterCriterion
Package: clustering.evaluation

Plot clustering evaluation object criterion values


h = plot(eva)


plot(eva) displays a plot of the criterion values versus the number of clusters, based on the values stored in the clustering evaluation object eva.

h = plot(eva) returns a handle to the plot line.

Input Arguments

expand all

Clustering evaluation data, specified as a clustering evaluation object. Create a clustering evaluation object using evalclusters.

Output Arguments

expand all

Handle to the plot line, returned as a scalar value.


expand all

Plot the criterion values versus the number of clusters for each clustering solution stored in a clustering evaluation object.

Load the sample data.

load fisheriris

The data contains length and width measurements from the sepals and petals of three species of iris flowers.

Create a clustering evaluation object. Cluster the data using kmeans, and evaluate the optimal number of clusters using the Calinski-Harabasz criterion.

rng('default');  % For reproducibility
eva = evalclusters(meas,'kmeans','CalinskiHarabasz','KList',[1:6]);

Plot the Calinski-Harabasz criterion values for each number of clusters tested.


Figure contains an axes object. The axes object contains 2 objects of type line.

The plot shows that the highest Calinski-Harabasz value occurs at three clusters, suggesting that the optimal number of clusters is three.

See Also