MATLAB Answers

huda nawaf

I used the same data, but not get the same figure

Asked by huda nawaf
on 5 Sep 2012

hi,

I try to built elbow code to determine the no. of clusters.I used the same data that used in the following link:

http://stackoverflow.com/questions/6645895/calculating-the-percentage-of-variance-measure-for-k-means#comment7854687_6645895

why I'm not get the same figure of elbow code in above link?

x = iris_dataset;
x=x';
 d=kmeans(x,9);
   for i=1:10
        a=find(d==i);
         for j=1:length(a)
             cluster(i,j)=a(j);
         end
   end
         for i=1:9
       cluster1{i}=cluster(i,:);
       var1(i)=var(cluster1{i});
         end
   s=sum(var1)/9;
   s1=var1/s;
  y(1:9)=1:9;
     plot(y,s1)

thanks in advance

  0 Comments

Tags

Products

No products are associated with this question.

1 Answer

Answer by Doug Hull
on 6 Sep 2012
 Accepted answer

KMEANS DOC

It looks to me like you are using the default settings for KMeans for the Start Parameter. This chooses a random starting subset. KMeans is NOT deterministic. You should expect different results each time, it is the nature of the algorithm.

  2 Comments

huda nawaf
on 9 Sep 2012

I do not think the reason in kmeans , but relate with somthing like scaling that thing I did not understand it.

thanks

Oleg Komarov
on 9 Sep 2012

The reason IS in the randomized selection of the start position in kmeans.

Compare d between two runs of kmeans.


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today