spark conversion from RowMatrix to CoordinateMatrix in scala

时间:2015-09-01 22:40:01

标签: scala matrix apache-spark distributed

I am trying to perform some operations in Distributed matrix space in Scala Spark, and I am wondering if there is any straightforward way to convert a distributed RowMatrix to a distributed CoordinateMatrix?

For example, if

rdd_input = Array[org.apache.spark.mllib.linalg.Vector] = Array([10], [0], [0], [40])

The conversion of RowMatrix to 2 X 2 dense matrix was accomplished by,

rdd_input.zipWithIndex.groupBy{case (x, i) => i / 2}.map(_._2.map(_._1))

If the Matrix is sparse, how can I convert this matrix to a CoordinateMatrix?

Any help is appreciated.

0 个答案:

没有答案