Matlab cluster coding - plot scatter graph

前端 未结 1 1710
后悔当初
后悔当初 2021-01-15 15:10

I have a daily annual energy consumption data set for a one year period. I would like to show a scatter graph of this data set separated into the four clusters which I expec

相关标签:
1条回答
  • 2021-01-15 16:01

    Consider the following example of hierarchical clustering applied to the Fisher Iris dataset (150 instances, each point is 4-dimensional):

    %# 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
    

    dendogram scatter

    0 讨论(0)
提交回复
热议问题