Repository: spark
Updated Branches:
  refs/heads/master 752d9eeb9 -> 87bc4112c


[SPARK-18698][ML] Adding public constructor that takes uid for IndexToString

## What changes were proposed in this pull request?

Based on SPARK-18698, this adds a public constructor that takes a UID for 
IndexToString.  Other transforms have similar constructors.

## How was this patch tested?

A unit test was added to verify the new functionality.

Author: Ilya Matiach <[email protected]>

Closes #16436 from imatiach-msft/ilmat/fix-indextostring.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/87bc4112
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/87bc4112
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/87bc4112

Branch: refs/heads/master
Commit: 87bc4112c5d766839aaa3876e19dae3a67108265
Parents: 752d9ee
Author: Ilya Matiach <[email protected]>
Authored: Thu Dec 29 13:25:49 2016 -0800
Committer: Joseph K. Bradley <[email protected]>
Committed: Thu Dec 29 13:25:49 2016 -0800

----------------------------------------------------------------------
 .../scala/org/apache/spark/ml/feature/StringIndexer.scala    | 2 +-
 .../org/apache/spark/ml/feature/StringIndexerSuite.scala     | 8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/87bc4112/mllib/src/main/scala/org/apache/spark/ml/feature/StringIndexer.scala
----------------------------------------------------------------------
diff --git 
a/mllib/src/main/scala/org/apache/spark/ml/feature/StringIndexer.scala 
b/mllib/src/main/scala/org/apache/spark/ml/feature/StringIndexer.scala
index 0a4d31d..a503411 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/feature/StringIndexer.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/feature/StringIndexer.scala
@@ -255,7 +255,7 @@ object StringIndexerModel extends 
MLReadable[StringIndexerModel] {
  * @see `StringIndexer` for converting strings into indices
  */
 @Since("1.5.0")
-class IndexToString private[ml] (@Since("1.5.0") override val uid: String)
+class IndexToString @Since("2.2.0") (@Since("1.5.0") override val uid: String)
   extends Transformer with HasInputCol with HasOutputCol with 
DefaultParamsWritable {
 
   @Since("1.5.0")

http://git-wip-us.apache.org/repos/asf/spark/blob/87bc4112/mllib/src/test/scala/org/apache/spark/ml/feature/StringIndexerSuite.scala
----------------------------------------------------------------------
diff --git 
a/mllib/src/test/scala/org/apache/spark/ml/feature/StringIndexerSuite.scala 
b/mllib/src/test/scala/org/apache/spark/ml/feature/StringIndexerSuite.scala
index a6bbb94..2d0e63c 100644
--- a/mllib/src/test/scala/org/apache/spark/ml/feature/StringIndexerSuite.scala
+++ b/mllib/src/test/scala/org/apache/spark/ml/feature/StringIndexerSuite.scala
@@ -20,7 +20,7 @@ package org.apache.spark.ml.feature
 import org.apache.spark.{SparkException, SparkFunSuite}
 import org.apache.spark.ml.attribute.{Attribute, NominalAttribute}
 import org.apache.spark.ml.param.ParamsSuite
-import org.apache.spark.ml.util.{DefaultReadWriteTest, MLTestingUtils}
+import org.apache.spark.ml.util.{DefaultReadWriteTest, Identifiable, 
MLTestingUtils}
 import org.apache.spark.mllib.util.MLlibTestSparkContext
 import org.apache.spark.sql.Row
 import org.apache.spark.sql.functions.col
@@ -219,6 +219,12 @@ class StringIndexerSuite
     testDefaultReadWrite(t)
   }
 
+  test("SPARK 18698: construct IndexToString with custom uid") {
+    val uid = "customUID"
+    val t = new IndexToString(uid)
+    assert(t.uid == uid)
+  }
+
   test("StringIndexer metadata") {
     val data = Seq((0, "a"), (1, "b"), (2, "c"), (3, "a"), (4, "a"), (5, "c"))
     val df = data.toDF("id", "label")


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to