How can I get clusters from a distance matrix using PHP?

I have a distance matrix as a two-dimensional array, for example:

matrix distance

So, I need to find clusters, elements using it. I can do this using hierarchical clustering, for example, k-means. I found here such an example of PHP K-Means

How can I convert my two-dimensional array to an array of points listed in this example?

$points = [
[80,55],[86,59],[19,85],[41,47],[57,58],
[76,22],[94,60],[13,93],[90,48],[52,54],
[62,46],[88,44],[85,24],[63,14],[51,40],
[75,31],[86,62],[81,95],[47,22],[43,95],
[71,19],[17,65],[69,21],[59,60],[59,12],
[15,22],[49,93],[56,35],[18,20],[39,59],
[50,15],[81,36],[67,62],[32,15],[75,65],
[10,47],[75,18],[13,45],[30,62],[95,79],
[64,11],[92,14],[94,49],[39,13],[60,68],
[62,10],[74,44],[37,42],[97,60],[47,73],
];
+4
source share
1 answer

First: a nitpick: k-Means is not a hierarchical clustering algorithm, see https://www.quora.com/What-is-the-difference-between-k-means-and-hierarchical-clustering for details information about the difference.

-: , , . , k-Means, , API, , , :

+1

Source: https://habr.com/ru/post/1690075/


All Articles