I have logistic regression model and I want to calculating recall@25
val predictionAndLabels = predicted
.select("prediction", "label")
.rdd.map(x => (x(0).asInstanceOf[Array[Double]], x(1)
.asInstanceOf[Array[Double]]))
val matrix = new RankingMetrics(predictionAndLabels)
Array(1, 25).foreach { k =>
println(s"Recall at $k = ${matrix.RecallAt(k)}")
}
this exception appear
java.lang.Double cannot be cast to [D
How to solve it?
RankingMetrics requires RDD(array, array) where as you are having RDD(double,double) which means you are passing the INVALID arguments.
In General for Type conversion, map transformation used
Assuming that predictionAndLabels.rdd type is RDD(double,double)
pairArrRDD = predictionAndLabels.rdd.map(x => (Array(x._1),Array(x._2))) //this is in scala
val matrix = new RankingMetrics( pairArrRDD )
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.