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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]