K-means cosine zero-vector detection
7 ビュー (過去 30 日間)
古いコメントを表示
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,
0 件のコメント
回答 (2 件)
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 件のコメント
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
2014 年 3 月 13 日
Dow, I am facing the same problem. Please share if you finally managed to do K-means cosine clustering.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!