diff options
author | Xiangrui Meng <meng@databricks.com> | 2016-06-21 15:52:31 -0700 |
---|---|---|
committer | Xiangrui Meng <meng@databricks.com> | 2016-06-21 15:52:31 -0700 |
commit | 9493b079a0050f0a6f4936c17622b96fb185b67f (patch) | |
tree | ab1904e8054a6a19f8e0e2542561d61a12f78049 /mllib | |
parent | f4e8c31adf45af05751e0d77aefb5cacc58375ee (diff) | |
download | spark-9493b079a0050f0a6f4936c17622b96fb185b67f.tar.gz spark-9493b079a0050f0a6f4936c17622b96fb185b67f.tar.bz2 spark-9493b079a0050f0a6f4936c17622b96fb185b67f.zip |
[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 <meng@databricks.com>
Closes #13821 from mengxr/SPARK-16118.
Diffstat (limited to 'mllib')
-rw-r--r-- | mllib/src/main/scala/org/apache/spark/ml/feature/OneHotEncoder.scala | 4 | ||||
-rw-r--r-- | mllib/src/test/scala/org/apache/spark/ml/feature/OneHotEncoderSuite.scala | 4 |
2 files changed, 7 insertions, 1 deletions
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 4fafc1e349..01828ede6b 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) 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 7841b4fbc7..d41eeec132 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 => |