Skip to content

Commit 9e82273

Browse files
dahlemjkbradley
authored andcommitted
[SPARK-11343][ML] Documentation of float and double prediction/label columns in RegressionEvaluator
felixcheung , mengxr Just added a message to require() Author: Dominik Dahlem <dominik.dahlem@gmail.combination> Closes #9598 from dahlem/ddahlem_regression_evaluator_double_predictions_message_04112015. (cherry picked from commit a0046e3) Signed-off-by: Joseph K. Bradley <joseph@databricks.com>
1 parent b1d5a78 commit 9e82273

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

mllib/src/main/scala/org/apache/spark/ml/evaluation/RegressionEvaluator.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,15 @@ final class RegressionEvaluator @Since("1.4.0") (@Since("1.4.0") override val ui
7373
@Since("1.4.0")
7474
override def evaluate(dataset: DataFrame): Double = {
7575
val schema = dataset.schema
76+
val predictionColName = $(predictionCol)
7677
val predictionType = schema($(predictionCol)).dataType
77-
require(predictionType == FloatType || predictionType == DoubleType)
78+
require(predictionType == FloatType || predictionType == DoubleType,
79+
s"Prediction column $predictionColName must be of type float or double, " +
80+
s" but not $predictionType")
81+
val labelColName = $(labelCol)
7882
val labelType = schema($(labelCol)).dataType
79-
require(labelType == FloatType || labelType == DoubleType)
83+
require(labelType == FloatType || labelType == DoubleType,
84+
s"Label column $labelColName must be of type float or double, but not $labelType")
8085

8186
val predictionAndLabels = dataset
8287
.select(col($(predictionCol)).cast(DoubleType), col($(labelCol)).cast(DoubleType))

0 commit comments

Comments
 (0)