简体   繁体   中英

org.apache.spark.mllib.linalg.Vector to DataFrame scala

I have an output like the following

val output = Vectors.dense(Vectors.dense(pred.toDouble).toArray ++ predProb.toArray)
output: org.apache.spark.mllib.linalg.Vector = [0.0,0.9279938116118619,0.07200618838813808]

I want to convert that into a DataFrame with the following as column values

case class Prob(Pred: Double, NoProb: Double, YesProb: Double)

Can somebody please help.

Thanks

Bala

val df = output.map(_。toArray).map {case Array(p0,p1,p2)=> Prob(p0,p1,p2)}。toDF()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM