필터 지우기
필터 지우기

how to access the number of each sample after clustering ?

조회 수: 1 (최근 30일)
fred bnm
fred bnm 2016년 6월 12일
편집: Image Analyst 2016년 6월 12일
i have 100 sample with 5 attribute for each of them.how to clustering this 100 sample in 3 cluster? i want to plot data and access the number of each sample after clustering.

채택된 답변

Image Analyst
Image Analyst 2016년 6월 12일
편집: Image Analyst 2016년 6월 12일
Use the kmeans() function in the Statistics and Machine Learning Toolbox:
numberOfClasses = 3;
assignedClasses = kmeans(yourData100by5, numberOfClasses);
% Find out which rows are assigned to class #1:
class1Rows = assignedClasses == 1;
% Extract only those observations
class1data = yourData100by5(class1Rows, :); % A 5 column matrix.
% Find out which rows are assigned to class #2:
class2Rows = assignedClasses == 2;
% Extract only those observations
class2data = yourData100by5(class2Rows, :); % A 5 column matrix.
% Find out which rows are assigned to class #3:
class3Rows = assignedClasses == 3;
% Extract only those observations
class3data = yourData100by5(class3Rows, :); % A 5 column matrix.
I don't know how you want to plot a 3 dimensional matrix though. Maybe you can pick just 3 of the 5 features and use scatter3() or plot3().

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by