Skip to content
Snippets Groups Projects
Commit a0046e37 authored by Dominik Dahlem's avatar Dominik Dahlem Committed by Joseph K. Bradley
Browse files

[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.
parent 765c67f5
No related branches found
No related tags found
No related merge requests found
...@@ -73,10 +73,15 @@ final class RegressionEvaluator @Since("1.4.0") (@Since("1.4.0") override val ui ...@@ -73,10 +73,15 @@ final class RegressionEvaluator @Since("1.4.0") (@Since("1.4.0") override val ui
@Since("1.4.0") @Since("1.4.0")
override def evaluate(dataset: DataFrame): Double = { override def evaluate(dataset: DataFrame): Double = {
val schema = dataset.schema val schema = dataset.schema
val predictionColName = $(predictionCol)
val predictionType = schema($(predictionCol)).dataType 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 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 val predictionAndLabels = dataset
.select(col($(predictionCol)).cast(DoubleType), col($(labelCol)).cast(DoubleType)) .select(col($(predictionCol)).cast(DoubleType), col($(labelCol)).cast(DoubleType))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment