Convert Matrix to RowMatrix in Apache Spark using Scala

前端 未结 2 1175
自闭症患者
自闭症患者 2021-01-06 00:59

I\'d really like to convert my org.apache.spark.mllib.linalg.Matrix to org.apache.spark.mllib.linalg.distributed.RowMatrix

I can do it as such:

val         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-06 01:27

    small correction in above code: we need to use Vectors.dense instead of new DenseVector

    val vectors = rows.map(row =>  Vectors.dense(row.toArray))
    

提交回复
热议问题