how apply k-means on a n by m matrix based on rows
조회 수: 1 (최근 30일)
이전 댓글 표시
I want to apply a kmeans clustering with cosine distance on a n by m matrix and I want to define each row as a sample. how can I do that?
For example, I have a 30x50 matrix and I want to cluster them based on cosine similarity of each of the rows. Means that I have 50 samples. Consider each row as an image that I want to cluster them based on cosine similarity.

댓글 수: 0
답변 (1개)
Image Analyst
2021년 9월 22일
So you have 30 images, and for each image there are 50 measurements/features/samples or whatever you want to call the data. So why can't you just call kmeans
numClusters = 4; % Whatever you want.
[indexes, clusterCentroids] = kmeans(data, numClusters, 'distance', 'cosine');
Why do you want that distance metric (cosine) instead of any of the other, more common, distance metrics?
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Cluster Analysis and Anomaly Detection에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!