I have the following two functions that do not compile due to 3 errors:
RegressionMetrics
:Cannot resolve constructor
_.nonEmpty
:Type mismatch, expected ((Double,Double))=>Boolean, actual ((Double,Double))=>Any
reduce(_+_)
:Cannot resolve symbol +
.
Code:
import org.apache.spark.mllib.evaluation.RegressionMetrics
//..
def getRMSE (rdd: RDD): Double = {
val metrics = new RegressionMetrics(rdd)
metrics.rootMeanSquaredError
}
def calculateRMSE(output: DStream[(Double, Double)]): Double = {
output.filter(_.nonEmpty).map(getRMSE).reduce(_+_)
}
test("Test1") {
// do some data preprocessing
// call the function calculateRMSE
}
Any idea how to fix these errors?
P.S: The strange thing is that when I put val metrics = new RegressionMetrics(rdd)
inside the test
is compiles without any problem.
UPDATE:
I was able to solve issue #1 by adding (Double,Double)
to RDD
:
def getRMSE(rdd : RDD[(Double, Double)]) : Double = {
val metrics = new RegressionMetrics(rdd)
metrics.rootMeanSquaredError
}