K means clustering with initial guess centroids given

16 ビュー (過去 30 日間)
Riordan Moloney
Riordan Moloney 2020 年 12 月 30 日
回答済み: Rishabh Mishra 2021 年 1 月 6 日
I have the problem where i have been given a 10,000x1 selection of data points, 100 points collected every weekend for 100 weeks. I am also given a 100x1 text file which i should use as the 'initial guess' for centroids. I need to iterate through the k means clustering algorithym until the distance between centroid locations is 0.00001. Please help, thanks
  5 件のコメント
Image Analyst
Image Analyst 2020 年 12 月 30 日
Looks like you're supposed to write your own kmeans function instead of using the built-in one, right?
Riordan Moloney
Riordan Moloney 2020 年 12 月 30 日
Yes this is what i am strugggling with, I assume i will need to use implemented for loops, but the data variables are of different sizes and i am not sure how to test which value in the initial centroids is closest to the particular value i will be testing in the results data.

サインインしてコメントする。

回答 (1 件)

Rishabh Mishra
Rishabh Mishra 2021 年 1 月 6 日
Hi,
I would like to make following assumptions:
  1. The points over which you are applying k-means clustering are 2-D coordinates. The points are represented using 2 dimensions. I.e., (x,y).
  2. arr’ - the 10000 x 2 array of 10000 points each with 2 dimensions.
  3. ‘centroid’ - the 100 x 2 of 100 centroids each with 2 dimensions.
Use the code below to perform k-means clustering on given points:
k = 100; % number of cluster
[idx,C] = kmeans(arr,k,'Start',centroid);
% idx - defines which cluster a given point is assigned to
% C - gives co-ordinate of all the 100 cluster centroids
Hope this helps.

Community Treasure Hunt

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

Start Hunting!

Translated by