You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by mengxr <gi...@git.apache.org> on 2016/02/12 11:06:27 UTC

[GitHub] spark pull request: [SPARK-12375] [ML] add handleinvalid for vecto...

Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10466#discussion_r52723364
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/feature/VectorIndexer.scala ---
    @@ -345,12 +350,27 @@ class VectorIndexerModel private[ml] (
       /** @group setParam */
       def setOutputCol(value: String): this.type = set(outputCol, value)
     
    +  /** @group setParam */
    +  def setHandleInvalid(value: String): this.type = set(handleInvalid, value)
    +  setDefault(handleInvalid, "error")
    +
       override def transform(dataset: DataFrame): DataFrame = {
         transformSchema(dataset.schema, logging = true)
         val newField = prepOutputField(dataset.schema)
    +
    +    val filteredDataset = (getHandleInvalid) match {
    +      case "skip" => {
    +        val filterer = udf { label: Vector =>
    +          categoryMaps.forall { case (index, categoryMap) => categoryMap.contains(label(index)) }
    --- End diff --
    
    Did you check the performance? This could be quite expensive. Another option is to catch errors in `transformFunc` and set output to null, and then filter out null values. It is less accurate but could be faster.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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