You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by me...@apache.org on 2016/06/21 22:52:34 UTC
spark git commit: [SPARK-16118][MLLIB] add getDropLast to
OneHotEncoder
Repository: spark
Updated Branches:
refs/heads/master f4e8c31ad -> 9493b079a
[SPARK-16118][MLLIB] add getDropLast to OneHotEncoder
## What changes were proposed in this pull request?
We forgot the getter of `dropLast` in `OneHotEncoder`
## How was this patch tested?
unit test
Author: Xiangrui Meng <me...@databricks.com>
Closes #13821 from mengxr/SPARK-16118.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/9493b079
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/9493b079
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/9493b079
Branch: refs/heads/master
Commit: 9493b079a0050f0a6f4936c17622b96fb185b67f
Parents: f4e8c31
Author: Xiangrui Meng <me...@databricks.com>
Authored: Tue Jun 21 15:52:31 2016 -0700
Committer: Xiangrui Meng <me...@databricks.com>
Committed: Tue Jun 21 15:52:31 2016 -0700
----------------------------------------------------------------------
.../main/scala/org/apache/spark/ml/feature/OneHotEncoder.scala | 4 ++++
.../scala/org/apache/spark/ml/feature/OneHotEncoderSuite.scala | 4 +++-
2 files changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/9493b079/mllib/src/main/scala/org/apache/spark/ml/feature/OneHotEncoder.scala
----------------------------------------------------------------------
diff --git a/mllib/src/main/scala/org/apache/spark/ml/feature/OneHotEncoder.scala b/mllib/src/main/scala/org/apache/spark/ml/feature/OneHotEncoder.scala
index 4fafc1e..01828ed 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/feature/OneHotEncoder.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/feature/OneHotEncoder.scala
@@ -59,6 +59,10 @@ class OneHotEncoder @Since("1.4.0") (@Since("1.4.0") override val uid: String) e
new BooleanParam(this, "dropLast", "whether to drop the last category")
setDefault(dropLast -> true)
+ /** @group getParam */
+ @Since("2.0.0")
+ def getDropLast: Boolean = $(dropLast)
+
/** @group setParam */
@Since("1.4.0")
def setDropLast(value: Boolean): this.type = set(dropLast, value)
http://git-wip-us.apache.org/repos/asf/spark/blob/9493b079/mllib/src/test/scala/org/apache/spark/ml/feature/OneHotEncoderSuite.scala
----------------------------------------------------------------------
diff --git a/mllib/src/test/scala/org/apache/spark/ml/feature/OneHotEncoderSuite.scala b/mllib/src/test/scala/org/apache/spark/ml/feature/OneHotEncoderSuite.scala
index 7841b4f..d41eeec 100644
--- a/mllib/src/test/scala/org/apache/spark/ml/feature/OneHotEncoderSuite.scala
+++ b/mllib/src/test/scala/org/apache/spark/ml/feature/OneHotEncoderSuite.scala
@@ -49,7 +49,9 @@ class OneHotEncoderSuite
val encoder = new OneHotEncoder()
.setInputCol("labelIndex")
.setOutputCol("labelVec")
- .setDropLast(false)
+ assert(encoder.getDropLast === true)
+ encoder.setDropLast(false)
+ assert(encoder.getDropLast === false)
val encoded = encoder.transform(transformed)
val output = encoded.select("id", "labelVec").rdd.map { r =>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org