You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Meeraj Kunnumpurath <me...@servicesymphony.com> on 2016/10/13 10:27:33 UTC
RowMatrix from DenseVector
Hello,
How do I create a row matrix from a dense vector. The following code,
doesn't compile.
val features = df.rdd.map(r =>
Vectors.dense(r.getAs[Double]("constant"),
r.getAs[Double]("sqft_living")))
val rowMatrix = new RowMatrix(features, features.count(), 2)
The compiler error
Error:(24, 33) type mismatch;
found : org.apache.spark.rdd.RDD[org.apache.spark.ml.linalg.Vector]
required: org.apache.spark.rdd.RDD[org.apache.spark.mllib.linalg.Vector]
val rowMatrix = new RowMatrix(features, features.count(), 2)
^
--
*Meeraj Kunnumpurath*
*Director and Executive PrincipalService Symphony Ltd00 44 7702 693597*
*00 971 50 409 0169meeraj@servicesymphony.com <me...@servicesymphony.com>*
Re: RowMatrix from DenseVector
Posted by Meeraj Kunnumpurath <me...@servicesymphony.com>.
Apologies, oversight, I had a mix of mllib and ml imports.
On Thu, Oct 13, 2016 at 2:27 PM, Meeraj Kunnumpurath <
meeraj@servicesymphony.com> wrote:
> Hello,
>
> How do I create a row matrix from a dense vector. The following code,
> doesn't compile.
>
> val features = df.rdd.map(r => Vectors.dense(r.getAs[Double]("constant"), r.getAs[Double]("sqft_living")))
> val rowMatrix = new RowMatrix(features, features.count(), 2)
>
> The compiler error
>
> Error:(24, 33) type mismatch;
> found : org.apache.spark.rdd.RDD[org.apache.spark.ml.linalg.Vector]
> required: org.apache.spark.rdd.RDD[org.apache.spark.mllib.linalg.Vector]
> val rowMatrix = new RowMatrix(features, features.count(), 2)
> ^
>
> --
> *Meeraj Kunnumpurath*
>
>
> *Director and Executive PrincipalService Symphony Ltd00 44 7702 693597*
>
> *00 971 50 409 0169meeraj@servicesymphony.com <me...@servicesymphony.com>*
>
--
*Meeraj Kunnumpurath*
*Director and Executive PrincipalService Symphony Ltd00 44 7702 693597*
*00 971 50 409 0169meeraj@servicesymphony.com <me...@servicesymphony.com>*