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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]