Did you try to treat RDD[(Double, Vector)] as RDD[LabeledPoint]? If that is the case, you need to cast them explicitly:
rdd.map { case (label, features) => LabeledPoint(label, features) } -Xiangrui On Mon, Apr 6, 2015 at 11:59 AM, Joanne Contact <joannenetw...@gmail.com> wrote: > Hello Sparkers, > > I kept getting this error: > > java.lang.ClassCastException: scala.Tuple2 cannot be cast to > org.apache.spark.mllib.regression.LabeledPoint > > I have tried the following to convert v._1 to double: > > Method 1: > > (if(v._1>0) 1d else 0d) > > Method 2: > > def bool2Double(b:Boolean): Double = { > if (b) 1.0 > else 0.0 > } > > bool2Double(v._1>0) > > Method 3: > implicit def bool2Double(b:Boolean): Double = { > if (b) 1.0 > else 0.0 > } > > > None of them works. > > Any advice would be appreciated. > > Thanks! > > J > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@spark.apache.org > For additional commands, e-mail: user-h...@spark.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@spark.apache.org For additional commands, e-mail: user-h...@spark.apache.org