spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Takeshi Yamamuro <linguin....@gmail.com>
Subject Re: Convert SparseVector column to Densevector column
Date Mon, 14 Nov 2016 05:34:55 GMT
Hi,

How about this?

import org.apache.spark.ml.linalg._
val toSV = udf((v: Vector) => v.toDense)
val df = Seq((0.1, Vectors.sparse(16, Array(0, 3), Array(0.1, 0.3))), (0.2,
Vectors.sparse(16, Array(0, 3), Array(0.1, 0.3)))).toDF("a", "b")
df.select(toSV($"b"))

// maropu


On Mon, Nov 14, 2016 at 1:20 PM, janardhan shetty <janardhanp22@gmail.com>
wrote:

> Hi,
>
> Is there any easy way of converting a dataframe column from SparseVector
> to DenseVector  using
>
> import org.apache.spark.ml.linalg.DenseVector API ?
>
> Spark ML 2.0
>



-- 
---
Takeshi Yamamuro

Mime
View raw message