You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by jk...@apache.org on 2015/12/09 03:54:16 UTC

spark git commit: [SPARK-11343][ML] Documentation of float and double prediction/label columns in RegressionEvaluator

Repository: spark
Updated Branches:
  refs/heads/master 765c67f5f -> a0046e379


[SPARK-11343][ML] Documentation of float and double prediction/label columns in RegressionEvaluator

felixcheung , mengxr

Just added a message to require()

Author: Dominik Dahlem <do...@gmail.combination>

Closes #9598 from dahlem/ddahlem_regression_evaluator_double_predictions_message_04112015.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/a0046e37
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/a0046e37
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/a0046e37

Branch: refs/heads/master
Commit: a0046e379bee0852c39ece4ea719cde70d350b0e
Parents: 765c67f
Author: Dominik Dahlem <do...@gmail.com>
Authored: Tue Dec 8 18:54:10 2015 -0800
Committer: Joseph K. Bradley <jo...@databricks.com>
Committed: Tue Dec 8 18:54:10 2015 -0800

----------------------------------------------------------------------
 .../apache/spark/ml/evaluation/RegressionEvaluator.scala    | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/a0046e37/mllib/src/main/scala/org/apache/spark/ml/evaluation/RegressionEvaluator.scala
----------------------------------------------------------------------
diff --git a/mllib/src/main/scala/org/apache/spark/ml/evaluation/RegressionEvaluator.scala b/mllib/src/main/scala/org/apache/spark/ml/evaluation/RegressionEvaluator.scala
index daaa174..b6b25ec 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/evaluation/RegressionEvaluator.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/evaluation/RegressionEvaluator.scala
@@ -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))


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org