k means clustering and SSE

답변 (1개)

Oleg Komarov
Oleg Komarov 2011년 4월 21일

1 개 추천

% Random data
xy = [rand(100,2)*2+3; rand(100,2)];
% Visualize clouds
scatter(xy(:,1),xy(:,2))
close
% Cluster
[idx,c,sse] = kmeans(xy,2);
% Plot clouds with centroids and legend
plot(xy(idx==1,1),xy(idx==1,2),'r.','MarkerSize',12)
hold on
plot(xy(idx==2,1),xy(idx==2,2),'b.','MarkerSize',12)
plot(c(:,1),c(:,2),'kx','MarkerSize',12,'LineWidth',2)
plot(c(:,1),c(:,2),'ko','MarkerSize',12,'LineWidth',2)
legend(['Cluster 1 (SSE: ' num2str(sse(1))],...
['Cluster 2 (SSE: ' num2str(sse(2))],...
'Centroids', 'Location','NW')

댓글 수: 2

Sai Aparna Kalvapalle
Sai Aparna Kalvapalle 2016년 8월 30일
Sorry but I fail to understand what 'kx','ko' are. Could someone elaborate?
Farrukh Hassan
Farrukh Hassan 2020년 12월 8일
This represents the shape 'ko' the shape of the centroid is circle. and kx shows the shape of the centroid be x.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Cluster Analysis and Anomaly Detection에 대해 자세히 알아보기

태그

질문:

2011년 4월 21일

댓글:

2020년 12월 8일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by