ここでは、行列内のベクトルのペア間の Jaccard 類似度を計算する例を理解しようとしています。
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
関数は最初の要素とは関係なく、ペアの 2 番目の要素を選択します。(0, x)
ペアはどの時点で消去されますか?