2
私はSpark Scalaを使用して、データフレーム行間のコサイン類似度を計算しています。コサイン類似度スパークデータフレームを計算する
データフレームフォーマットは、Iは行列を転置し、次の言及リンクを確認しようとした
+-------+--------------------+
| SKU| Features|
+-------+--------------------+
| 9970.0|[4.7143,0.0,5.785...|
|19676.0|[5.5,0.0,6.4286,4...|
| 3296.0|[4.7143,1.4286,6....|
|13658.0|[6.2857,0.7143,4....|
| 1.0|[4.2308,0.7692,5....|
| 513.0|[3.0,0.0,4.9091,5...|
| 3753.0|[5.9231,0.0,4.846...|
|14967.0|[4.5833,0.8333,5....|
| 2803.0|[4.2308,0.0,4.846...|
|11879.0|[3.1429,0.0,4.5,4...|
+-------+--------------------+
以下のデータフレームの
root
|-- SKU: double (nullable = true)
|-- Features: vector (nullable = true)
サンプル未満です。 Apache Spark Python Cosine Similarity over DataFrames、calculating-cosine-similarity-by-featurizing-the-text-into-vector-using-tf-idfしかし、私は、私は以下のサンプルコード
val irm = new IndexedRowMatrix(inClusters.rdd.map {
case (v,i:Vector) => IndexedRow(v, i)
}).toCoordinateMatrix.transpose.toRowMatrix.columnSimilarities
を試してみましたが、私は、私は次のリンクApache Spark: How to create a matrix from a DataFrame?をチェックすることができますが、
Error:(80, 12) constructor cannot be instantiated to expected type;
found : (T1, T2)
required: org.apache.spark.sql.Row
case (v,i:Vector) => IndexedRow(v, i)
以下のエラーを得たのよりよい解決策
があると信じていますScalaを使用して行います
私は私の質問の答えを更新し、それがエンドツーエンドでデータフレームを使用して行う方法はありますか? –