criterion matlab,Calinski-Harabasz criterion clustering evaluation object

Evaluate the optimal number of clusters using the Calinski-Harabasz clustering evaluation criterion.

Load the sample data.

load fisheriris;

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

Evaluate the optimal number of clusters using the Calinski-Harabasz criterion. Cluster the data using kmeans.

rng('default'); % For reproducibility

eva = evalclusters(meas,'kmeans','CalinskiHarabasz','KList',[1:6])

eva =

CalinskiHarabaszEvaluation with properties:

NumObservations: 150

InspectedK: [1 2 3 4 5 6]

CriterionValues: [Inf 513.9245 561.6278 530.4871 456.1279 469.5068]

OptimalK: 1

The OptimalK value indicates that, based on the Calinski-Harabasz criterion, the optimal number of clusters is three.

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

figure;

plot(eva);

cdca366e567769faf3f65eca57ae876e.png

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

Create a grouped scatter plot to examine the relationship between petal length and width. Group the data by suggested clusters.

PetalLength = meas(:,3);

PetalWidth = meas(:,4);

ClusterGroup = eva.OptimalY;

figure;

gscatter(PetalLength,PetalWidth,ClusterGroup,'rbg','xod');

a99ccd17dbdf5e3abc4e8dda114dacaa.png

The plot shows cluster 3 in the lower-left corner, completely separated from the other two clusters. Cluster 3 contains flowers with the smallest petal widths and lengths. Cluster 1 is in the upper-right corner, and contains flowers with the largest petal widths and lengths. Cluster 2 is near the center of the plot, and contains flowers with measurements between these two extremes.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值