Skip to content

Commit a0046e3

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 <[email protected]> Closes apache#9598 from dahlem/ddahlem_regression_evaluator_double_predictions_message_04112015.
1 parent 765c67f commit a0046e3

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

+7-2
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)