How would I convert the following DataFrame
val df = Seq(
(5.0, 1.0, 1.0, 3.0, 7.0),
(2.0, 0.0, 3.0, 4.0, 5.0),
(4.0, 0.0, 0.0, 6.0, 7.0)).toDF("m1", "m2", "m3", "m4", "m5")
//df: res166: org.apache.spark.sql.DataFrame = [m1: int, m2: int ... 3 more fields]
to an Array of dense vectors
val arrayDenseVectors = Array(
Vectors.dense(5.0, 1.0, 1.0, 3.0, 7.0),
Vectors.dense(2.0, 0.0, 3.0, 4.0, 5.0),
Vectors.dense(4.0, 0.0, 0.0, 6.0, 7.0))
//arrayDenseVectors: Array[org.apache.spark.mllib.linalg.Vector] = Array([5.0,1.0,1.0,3.0,7.0], [2.0,0.0,3.0,4.0,5.0], [4.0,0.0,0.0,6.0,7.0])
To further complicate the issue, df columns are of type Int
instead of Double