Matlab聚类编码——绘制散点图

And*_*ew 2 matlab cluster-analysis scatter-plot

我有一个为期一年的每日能源消耗数据集。我想显示这个数据集的散点图,分为我期望存在的四个集群(由于四个季节的差异)

我知道 matlab 集群函数可以做到这一点,但我的统计数据非常生疏,我希望得到一些指导,了解哪个函数最适合使用

谢谢

Amr*_*mro 5

考虑以下应用于 Fisher Iris 数据集(150 个实例,每个点为 4 维)的层次 聚类示例:

%# load dataset
load fisheriris

%# Construct agglomerative clusters
NUM = 3;
D = pdist(meas, 'euclid');
T = linkage(D, 'ward');
IDX = cluster(T, 'maxclust',NUM);

%# visualize the hierarchy of clusters
figure
h = dendrogram(T, 0, 'colorthreshold',mean(T(end-NUM+1:end-NUM+2,3)));
set(h, 'LineWidth',2)
set(gca, 'XTickLabel',[], 'TickLength',[0 0])

%# plot scatter of data colored by clusters
figure
scatter3(meas(:,1),meas(:,2),meas(:,3), 100, IDX, 'filled')
xlabel SL, ylabel SW, zlabel PL
Run Code Online (Sandbox Code Playgroud)

树状图 分散