Skip to content

Commit

Permalink
[SPARK-11343][ML] Documentation of float and double prediction/label …
Browse files Browse the repository at this point in the history
…columns in RegressionEvaluator

felixcheung , mengxr

Just added a message to require()

Author: Dominik Dahlem <[email protected]>

Closes apache#9598 from dahlem/ddahlem_regression_evaluator_double_predictions_message_04112015.
  • Loading branch information
dahlem authored and jkbradley committed Dec 9, 2015
1 parent 765c67f commit a0046e3
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,15 @@ final class RegressionEvaluator @Since("1.4.0") (@Since("1.4.0") override val ui
@Since("1.4.0")
override def evaluate(dataset: DataFrame): Double = {
val schema = dataset.schema
val predictionColName = $(predictionCol)
val predictionType = schema($(predictionCol)).dataType
require(predictionType == FloatType || predictionType == DoubleType)
require(predictionType == FloatType || predictionType == DoubleType,
s"Prediction column $predictionColName must be of type float or double, " +
s" but not $predictionType")
val labelColName = $(labelCol)
val labelType = schema($(labelCol)).dataType
require(labelType == FloatType || labelType == DoubleType)
require(labelType == FloatType || labelType == DoubleType,
s"Label column $labelColName must be of type float or double, but not $labelType")

val predictionAndLabels = dataset
.select(col($(predictionCol)).cast(DoubleType), col($(labelCol)).cast(DoubleType))
Expand Down

0 comments on commit a0046e3

Please sign in to comment.