You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/10/12 03:08:16 UTC

[GitHub] [spark] zhengruifeng commented on a change in pull request #26064: [SPARK-23578][ML][PYSPARK] Binarizer support multi-column

zhengruifeng commented on a change in pull request #26064: [SPARK-23578][ML][PYSPARK] Binarizer support multi-column
URL: https://github.com/apache/spark/pull/26064#discussion_r334217681
 
 

 ##########
 File path: mllib/src/main/scala/org/apache/spark/ml/feature/Binarizer.scala
 ##########
 @@ -69,66 +83,117 @@ final class Binarizer @Since("1.4.0") (@Since("1.4.0") override val uid: String)
   @Since("1.4.0")
   def setOutputCol(value: String): this.type = set(outputCol, value)
 
+  /** @group setParam */
+  @Since("3.0.0")
+  def setInputCols(value: Array[String]): this.type = set(inputCols, value)
+
+  /** @group setParam */
+  @Since("3.0.0")
+  def setOutputCols(value: Array[String]): this.type = set(outputCols, value)
+
   @Since("2.0.0")
   override def transform(dataset: Dataset[_]): DataFrame = {
     val outputSchema = transformSchema(dataset.schema, logging = true)
-    val schema = dataset.schema
-    val inputType = schema($(inputCol)).dataType
-    val td = $(threshold)
-    val metadata = outputSchema($(outputCol)).metadata
-
-    val binarizerUDF = inputType match {
-      case DoubleType =>
-        udf { in: Double => if (in > td) 1.0 else 0.0 }
-
-      case _: VectorUDT if td >= 0 =>
-        udf { vector: Vector =>
-          val indices = ArrayBuilder.make[Int]
-          val values = ArrayBuilder.make[Double]
-          vector.foreachActive { (index, value) =>
-            if (value > td) {
-              indices += index
-              values +=  1.0
+
+    val (inputColNames, outputColNames, tds) =
 
 Review comment:
   method `ParamValidators.checkSingleVsMultiColumnParams` in `transformSchema`  checks whether they are set together.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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