I have an endpoint in my API where I use this function geocluster from the library node-geocluster, where I give it a list of coordinates(latitude and longitude) and expect to have the return of a small amount of points, which are basically intermediates coordinates that clusters the given list of coordinates in smaller clusters. The algorithm is a variation from the k-means algorithm, using standard deviation, thus being called s-means.
My main problem is if there's two requests too quickly one after another, the API won't return the same clustering of coordinates for the users requesting it, sometimes with small variations, which is technically fine, but at some increasingly common times it returns completely different clusters of coordinates, which is very problematic and hard to predict or replicate, since it doesn't happen always.
So I would like to ask how could I avoid this behavior? Should I try another library similar to node-geocluster, which one? Should I change the code inside the library itself? How?
I've already tried changing the library code to avoid starting at a random coordinate from the given coordinates so it would avoid the random behavior - even though it's , but it didn't work. Also tried this with an ordered set of coordinates but no success either.
Thanks in advance!