Skip to content

Commit

Permalink
Take the negative instead of reciprocal.
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed Jun 19, 2015
1 parent c3dd8d9 commit 16e3b2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ final class RegressionEvaluator(override val uid: String)
val metrics = new RegressionMetrics(predictionAndLabels)
val metric = $(metricName) match {
case "rmse" =>
1 / metrics.rootMeanSquaredError
-metrics.rootMeanSquaredError
case "mse" =>
1 / metrics.meanSquaredError
-metrics.meanSquaredError
case "r2" =>
metrics.r2
case "mae" =>
1 / metrics.meanAbsoluteError
-metrics.meanAbsoluteError
}
metric
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ class RegressionEvaluatorSuite extends SparkFunSuite with MLlibTestSparkContext

// default = rmse
val evaluator = new RegressionEvaluator()
assert(evaluator.evaluate(predictions) ~== 0.1019382 absTol 0.001)
assert(evaluator.evaluate(predictions) ~== -0.1019382 absTol 0.001)

// r2 score
evaluator.setMetricName("r2")
assert(evaluator.evaluate(predictions) ~== 0.9998196 absTol 0.001)

// mae
evaluator.setMetricName("mae")
assert(evaluator.evaluate(predictions) ~== 0.08036075 absTol 0.001)
assert(evaluator.evaluate(predictions) ~== -0.08036075 absTol 0.001)
}
}

0 comments on commit 16e3b2c

Please sign in to comment.