aboutsummaryrefslogtreecommitdiff
path: root/mllib/src/main
diff options
context:
space:
mode:
authorHolden Karau <holden@pigscanfly.ca>2015-08-12 16:54:45 -0700
committerXiangrui Meng <meng@databricks.com>2015-08-12 16:54:45 -0700
commit6e409bc1357f49de2efdfc4226d074b943fb1153 (patch)
tree62ed93c1f037a858fdd98236e66b5de611c22d79 /mllib/src/main
parentcaa14d9dc9e2eb1102052b22445b63b0e004e3c7 (diff)
downloadspark-6e409bc1357f49de2efdfc4226d074b943fb1153.tar.gz
spark-6e409bc1357f49de2efdfc4226d074b943fb1153.tar.bz2
spark-6e409bc1357f49de2efdfc4226d074b943fb1153.zip
[SPARK-9909] [ML] [TRIVIAL] move weightCol to shared params
As per the TODO move weightCol to Shared Params. Author: Holden Karau <holden@pigscanfly.ca> Closes #8144 from holdenk/SPARK-9909-move-weightCol-toSharedParams.
Diffstat (limited to 'mllib/src/main')
-rw-r--r--mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala4
-rw-r--r--mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala15
-rw-r--r--mllib/src/main/scala/org/apache/spark/ml/regression/IsotonicRegression.scala16
3 files changed, 20 insertions, 15 deletions
diff --git a/mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala b/mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala
index 9e12f1856a..8c16c6149b 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala
@@ -70,7 +70,9 @@ private[shared] object SharedParamsCodeGen {
" For alpha = 0, the penalty is an L2 penalty. For alpha = 1, it is an L1 penalty.",
isValid = "ParamValidators.inRange(0, 1)"),
ParamDesc[Double]("tol", "the convergence tolerance for iterative algorithms"),
- ParamDesc[Double]("stepSize", "Step size to be used for each iteration of optimization."))
+ ParamDesc[Double]("stepSize", "Step size to be used for each iteration of optimization."),
+ ParamDesc[String]("weightCol", "weight column name. If this is not set or empty, we treat " +
+ "all instance weights as 1.0."))
val code = genSharedParams(params)
val file = "src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala"
diff --git a/mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala b/mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala
index a17d4ea960..c26768953e 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala
@@ -342,4 +342,19 @@ private[ml] trait HasStepSize extends Params {
/** @group getParam */
final def getStepSize: Double = $(stepSize)
}
+
+/**
+ * Trait for shared param weightCol.
+ */
+private[ml] trait HasWeightCol extends Params {
+
+ /**
+ * Param for weight column name. If this is not set or empty, we treat all instance weights as 1.0..
+ * @group param
+ */
+ final val weightCol: Param[String] = new Param[String](this, "weightCol", "weight column name. If this is not set or empty, we treat all instance weights as 1.0.")
+
+ /** @group getParam */
+ final def getWeightCol: String = $(weightCol)
+}
// scalastyle:on
diff --git a/mllib/src/main/scala/org/apache/spark/ml/regression/IsotonicRegression.scala b/mllib/src/main/scala/org/apache/spark/ml/regression/IsotonicRegression.scala
index f570590960..0f33bae30e 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/regression/IsotonicRegression.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/regression/IsotonicRegression.scala
@@ -21,7 +21,7 @@ import org.apache.spark.Logging
import org.apache.spark.annotation.Experimental
import org.apache.spark.ml.{Estimator, Model}
import org.apache.spark.ml.param._
-import org.apache.spark.ml.param.shared.{HasFeaturesCol, HasLabelCol, HasPredictionCol}
+import org.apache.spark.ml.param.shared.{HasFeaturesCol, HasLabelCol, HasPredictionCol, HasWeightCol}
import org.apache.spark.ml.util.{Identifiable, SchemaUtils}
import org.apache.spark.mllib.linalg.{Vector, VectorUDT, Vectors}
import org.apache.spark.mllib.regression.{IsotonicRegression => MLlibIsotonicRegression, IsotonicRegressionModel => MLlibIsotonicRegressionModel}
@@ -35,19 +35,7 @@ import org.apache.spark.storage.StorageLevel
* Params for isotonic regression.
*/
private[regression] trait IsotonicRegressionBase extends Params with HasFeaturesCol
- with HasLabelCol with HasPredictionCol with Logging {
-
- /**
- * Param for weight column name (default: none).
- * @group param
- */
- // TODO: Move weightCol to sharedParams.
- final val weightCol: Param[String] =
- new Param[String](this, "weightCol",
- "weight column name. If this is not set or empty, we treat all instance weights as 1.0.")
-
- /** @group getParam */
- final def getWeightCol: String = $(weightCol)
+ with HasLabelCol with HasPredictionCol with HasWeightCol with Logging {
/**
* Param for whether the output sequence should be isotonic/increasing (true) or