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

    https://github.com/apache/spark/pull/16883#discussion_r104296367
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/feature/StringIndexer.scala ---
    @@ -163,25 +190,28 @@ class StringIndexerModel (
         }
         transformSchema(dataset.schema, logging = true)
     
    +    val metadata = NominalAttribute.defaultAttr
    +      .withName($(outputCol)).withValues(labels).toMetadata()
    --- End diff --
    
    Yep, that's what I meant:  In ```withValues(labels)```, labels can be set 
as:
    ```
    val labels = getHandleInvalid match {
      case StringIndexer.KEEP_UNSEEN_LABEL => labels :+ "__unknown"
      case _ => labels
    }
    ```
    
    I'm adding underscores to the attribute name to make it a little less 
likely to hit conflicts.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to