相关疑难解决方法(0)

计算两个纬度 - 经度点之间的距离?(Haversine配方)

如何计算纬度和经度指定的两点之间的距离?

为了澄清,我想要以公里为单位的距离; 这些要点使用WGS84系统,我想了解可用方法的相对准确性.

algorithm math maps latitude-longitude haversine

852
推荐指数
19
解决办法
72万
查看次数

如何计算火花中的距离矩阵?

我已经尝试过对样本进行配对,但是它需要大量的内存,因为100个样本会导致9900个样本的成本更高.什么是在火花中分布式环境中计算距离矩阵的更有效方法

这是我正在尝试的伪代码片段

val input = (sc.textFile("AirPassengers.csv",(numPartitions/2)))
val i = input.map(s => (Vectors.dense(s.split(',').map(_.toDouble))))
val indexed = i.zipWithIndex()                                                                       //Including the index of each sample
val indexedData = indexed.map{case (k,v) => (v,k)}

val pairedSamples = indexedData.cartesian(indexedData)

val filteredSamples = pairedSamples.filter{ case (x,y) =>
(x._1.toInt > y._1.toInt)  //to consider only the upper or lower trainagle
 }
filteredSamples.cache
filteredSamples.count
Run Code Online (Sandbox Code Playgroud)

上面的代码创建了对,但即使我的数据集包含100个样本,通过配对filteredSamples(上面)会产生4950样本,这对于大数据来说可能非常昂贵

bigdata apache-spark distance-matrix

8
推荐指数
2
解决办法
2845
查看次数