K-means cosine zero-vector detection

조회 수: 5 (최근 30일)
Dow
Dow 2012년 5월 9일
답변: MML 2014년 3월 13일
I keep getting this error:
Error using kmeans (line 145) Some points have small relative magnitudes, making them effectively zero. Either remove those points, or choose a distance other than 'cosine'.
Error in runkmeans (line 7) [L, C]=kmeans(data, 10, 'Distance', 'cosine', 'EmptyAction', 'drop')
I wonder if anyone can tell me what the criterion is that Matlab uses in order to decide whether a point has a "small relative magnitudes" and is "effectively zero"?
I would love to remove the points, but I don't know how to detect them. It is not simply zero-vectors, because if I force the vector to be non-zero by adding a 1 at the end, I still get this error.
Any help would be greatly appreciated!
Thanks,

답변 (2개)

Tom Lane
Tom Lane 2012년 5월 9일
The function wants to treat each row of the data matrix as a point in some space with dimension size(data,2). Imagine rays extending from the origin to the points represented by each row. For cosine distance, the function wants to normalize each ray to have length 1. It does something like this:
dnorm = sqrt(sum(data.^2, 2));
Try computing this yourself, and see if the minimum value is tiny compared with the maximum value. If that's the case (ratio less than eps), the function is declaring that one point is so close to the origin that it's not reasonable to assign an angle to it.
If you believe the disparity in magnitudes of the points is not a problem, you could try normalizing each row to unit length before sending it into kmeans.
  댓글 수: 2
Dow
Dow 2012년 5월 9일
Thanks Tom! I'll try that. Please forgive my ignorance, but what is the value of eps?
Tom Lane
Tom Lane 2012년 5월 9일
Just type "eps" at the MATLAB command line and you'll see its numeric value. Type "help eps" for more details.

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


MML
MML 2014년 3월 13일
Dow, I am facing the same problem. Please share if you finally managed to do K-means cosine clustering.

Community Treasure Hunt

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

Start Hunting!

Translated by