我想了解計算矩陣中向量對之間的Jaccard相似度的示例here。爲什麼映射對會被刪除?
val aBinary = adjacencyMatrix.binarizeAs[Double]
// intersectMat holds the size of the intersection of row(a)_i n row (b)_j
val intersectMat = aBinary * aBinary.transpose
val aSumVct = aBinary.sumColVectors
val bSumVct = aBinary.sumRowVectors
//Using zip to repeat the row and column vectors values on the right hand
//for all non-zeroes on the left hand matrix
val xMat = intersectMat.zip(aSumVct).mapValues(pair => pair._2)
val yMat = intersectMat.zip(bSumVct).mapValues(pair => pair._2)
爲什麼最後評論提到非零值?據我所知,._2
函數選擇一對獨立於第一個元素的第二個元素。 (0, x)
對在什麼時候消失了?