zhengruifeng commented on a change in pull request #26439: [SPARK-29801][ML] ML 
models unify toString method
URL: https://github.com/apache/spark/pull/26439#discussion_r344429040
 
 

 ##########
 File path: mllib/src/main/scala/org/apache/spark/ml/feature/Bucketizer.scala
 ##########
 @@ -215,6 +215,13 @@ final class Bucketizer @Since("1.4.0") (@Since("1.4.0") 
override val uid: String
   override def copy(extra: ParamMap): Bucketizer = {
     defaultCopy[Bucketizer](extra).setParent(parent)
   }
+
+  @Since("3.0.0")
+  override def toString: String = {
+    s"Bucketizer: uid=$uid" +
+      get(inputCols).map(c => s", numInputCols=${c.length}").getOrElse("") +
+      get(outputCols).map(c => s", numOutputCols=${c.length}").getOrElse("")
+  }
 }
 
 
 Review comment:
   I test this in REPL:
   ```
   scala> val binarizer: Binarizer = new Binarizer()
   binarizer: org.apache.spark.ml.feature.Binarizer = Binarizer: 
uid=binarizer_3eab2c2d88f6
   
   scala> binarizer.setInputCols(Array("a", "b"))
   res3: binarizer.type = Binarizer: uid=binarizer_3eab2c2d88f6, numInputCols=2
   
   scala> binarizer.setOutputCols(Array("c", "d"))
   res4: binarizer.type = Binarizer: uid=binarizer_3eab2c2d88f6, 
numInputCols=2, numOutputCols=2
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to