我发现以下算法可以完美处理单个值 [2;4;56;10;34;....]
:https://radixcode.com/k-mean-clustering-algorithm-implementation-in-c-java
现在我想用 geolocation coordinates
-
例如,假设我有以下对:
Longitude: 759849.934, Latitude: 193728.08
Longitude: 760151.603, Latitude: 192624.342
Longitude: 759217.306, Latitude: 191895.671
Longitude: 758446.428, Latitude: 191074.83
Longitude: 758422.0, Latitude: 192359.0
有没有办法根据Longitude
和Latitude
计算出一个值来应用这个算法?
最佳答案
有几种方法可以做到这一点,但这些方法不适合将 Geo 点聚类,将坐标视为二维 vector ,因此您可以使用所有 vector 范数将它们转换为一维值 see her for different norms但这对你没有太大帮助。
for (int c : cz) {
row.add(abs(c - aItem));
}
groups.get(row.indexOf(Collections.min(row))).add(aItem);
row.removeAll(row);
完美实现的 K-Means 也将距离函数作为参数。在 for 循环中,您看到您的代码使用绝对值 abs(c - aItem)
作为距离函数,您需要更改它以使用合适的距离函数 look here例如。
关于具有经度和纬度值的 Java K-Means,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46278920/