필터 지우기
필터 지우기

Why kmeans gives different results each time?

조회 수: 12 (최근 30일)
huda nawaf
huda nawaf 2014년 12월 18일
댓글: huda nawaf 2014년 12월 19일
* *I have square binary similarity matrix show the social relation among users, where o means no relation between two users and 1 means there is relation between them.
I used kmeans to do clustering*
f1=dlmread('d:\matlab\r2011a\bin\paper_comm\link_flixster_bin1.txt');
c=kmeans(f1,3);
When run the kmeans more than one times, the results are different.
for example at firs time the cluster 1= 4448 users , cluster 2= 434, and cluster 3=118
But, in second times cluster 1= 4880 users , cluster 2= 119, and cluster 3=1
Why the results are different??*

채택된 답변

John D'Errico
John D'Errico 2014년 12월 18일
kmeans uses random starting values. (READ THE HELP. I just did to verify this.) So why would you expect that the solution will be identical if the start points are not?

추가 답변 (1개)

Chetan Rawal
Chetan Rawal 2014년 12월 18일
As John mentioned, the clustering happens by starting at random points, automatically selected by the algorithm. That is why in such a optimization/machine learning problems, you should try multiple iterations and use a validation data set if possible. To get the results closer between different runs, you can try to:
  • Increase number of iterations by increasing 'MaxIter'
  • Use your own starting points with the 'start' name-value pair
Starting with your own seeds instead of randomly selected seeds by MATLAB will ensure a consistent answer.
  댓글 수: 2
huda nawaf
huda nawaf 2014년 12월 19일
thanks
huda nawaf
huda nawaf 2014년 12월 19일
how start with my seeds? and how set the seed?
thanks

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by