MATLAB K-Means Algorithm with Arbitrary Distance Function (Chebyshev Distance)

Is there a way to set a different distance in K-value than these five implemented in Matlab, for example Chebyshev distance:

D = max (abs (hee-hee))

Thank.

Best,

Pavlos

+3


source to share


5 answers


If you don't have any specific reason for using K-means and can handle hierarchical agglomeration clustering, you can use clusterdata

. It also works with Chebyshev distance.



+1


source


This might help you.

http://www.purplemath.com/modules/distform.htm

http://www.mathwarehouse.com/algebra/distance_formula/index.php



In addition, there is another concept of calculating the distance between two points called " City blocking ), which is something analogous to the distance ABSOLUTE of two points. Example:

Distance, d = |x2-x1| + |y2-y1|

OR          d = |x1-x2| + |y1-y2|

(Since the results are absolute, any shape will do) Check and try.

0


source


The Chebyshev distance is equivalent to infinity norm . This should help you find Matlab documentation.

I have read the documentation from K-means in Matlab and there is no mention of extending the function with additional distance norms. So you should probably implement it yourself.

Another option is to look for a mapping from Linf to L2, but that doesn't exist. I'm sorry.

0


source


Second, hierarchical clustering can be more according to what you want, since you can easily specify the distance function.

However, if you really want to use k-means, you can create a distance matrix using whatever function you like and break your object space distance matrix with SVD. Then execute k-means in a new object space represented by dozens of SVDs.

I don't know that K-means will converge with other distance marks.

0


source


I have created MATLAB code for very simple K-Means that accepts an arbitrary distance function.

You can get the code in the GitHub Repository .

Below are the results for three different distance metrics:

enter image description here

enter image description here

enter image description here

0


source







All Articles