plot

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

Plot clustering evaluation object criterion values

Syntax

plot(eva)
h = plot(eva)

Description

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

eva — Clustering evaluation dataclustering evaluation object

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

Output Arguments

expand all

h — Handle to plot linescalar value

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

Examples

expand all

Plot the Clustering Evaluation Criterion Values

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;
plot(eva);

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

See Also

Was this topic helpful?