From db0ac937b9df678f7f58b26bab1afa43d77eb5a1 Mon Sep 17 00:00:00 2001 From: actuaryzhang Date: Thu, 29 Jun 2017 10:50:15 -0700 Subject: [PATCH] address comments --- .../main/scala/org/apache/spark/ml/feature/Instance.scala | 7 +------ .../spark/ml/regression/GeneralizedLinearRegression.scala | 6 ++++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/mllib/src/main/scala/org/apache/spark/ml/feature/Instance.scala b/mllib/src/main/scala/org/apache/spark/ml/feature/Instance.scala index 51389e9da1739..dd56fbbfa2b63 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/feature/Instance.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/feature/Instance.scala @@ -44,12 +44,7 @@ private[ml] case class OffsetInstance( offset: Double, features: Vector) { - /** Constructs from an [[Instance]] object and offset */ - def this(instance: Instance, offset: Double = 0.0) = { - this(instance.label, instance.weight, offset, instance.features) - } - /** Converts to an [[Instance]] object by leaving out the offset. */ - private[ml] def toInstance: Instance = Instance(label, weight, features) + def toInstance: Instance = Instance(label, weight, features) } diff --git a/mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala b/mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala index f145ae3f6a3b6..1d942f2f20169 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/regression/GeneralizedLinearRegression.scala @@ -139,10 +139,12 @@ private[regression] trait GeneralizedLinearRegressionBase extends PredictorParam * as 0.0. The feature specified as offset has a constant coefficient of 1.0. * @group param */ + @Since("2.3.0") final val offsetCol: Param[String] = new Param[String](this, "offsetCol", "The offset " + "column name. If this is not set or empty, we treat all instance offsets as 0.0") /** @group getParam */ + @Since("2.3.0") def getOffsetCol: String = $(offsetCol) /** Checks whether weight column is set and nonempty. */ @@ -333,7 +335,7 @@ class GeneralizedLinearRegression @Since("2.0.0") (@Since("2.0.0") override val * * @group setParam */ - @Since("2.2.0") + @Since("2.3.0") def setOffsetCol(value: String): this.type = set(offsetCol, value) /** @@ -990,7 +992,7 @@ class GeneralizedLinearRegressionModel private[ml] ( /** * Calculates the predicted value when offset is set. */ - def predict(features: Vector, offset: Double): Double = { + private def predict(features: Vector, offset: Double): Double = { val eta = predictLink(features, offset) familyAndLink.fitted(eta) }