Github user MLnick commented on the issue:
https://github.com/apache/spark/pull/16011
I don't think this is correct. The idea is `QuantileDiscretizer` skips NaN
when creating the buckets, but there will still be an error thrown during
`transform` (rather than `fit`) if NaNs are in data. Hence the test cases
intercepting the error. I think the test cases show it works, no?
e.g.
`model.transform(df).show` throws:
```
...
Caused by: org.apache.spark.SparkException: Bucketizer encountered NaN
value. To handle or skip NaNs, try setting Bucketizer.handleInvalid.
at
org.apache.spark.ml.feature.Bucketizer$.binarySearchForBuckets(Bucketizer.scala:188)
at
org.apache.spark.ml.feature.Bucketizer$$anonfun$1.apply$mcDD$sp(Bucketizer.scala:115)
at
org.apache.spark.ml.feature.Bucketizer$$anonfun$1.apply(Bucketizer.scala:114)
at
org.apache.spark.ml.feature.Bucketizer$$anonfun$1.apply(Bucketizer.scala:114)
```
Setting the param works:
```
scala> model.setHandleInvalid("skip").transform(df).show
+-----+------+
|input|result|
+-----+------+
| -0.9| 0.0|
| -0.5| 0.0|
| -0.3| 1.0|
| 0.0| 1.0|
| 0.2| 2.0|
| 0.5| 2.0|
| 0.9| 2.0|
+-----+------+
scala> model.setHandleInvalid("keep").transform(df).show
+-----+------+
|input|result|
+-----+------+
| -0.9| 0.0|
| -0.5| 0.0|
| -0.3| 1.0|
| 0.0| 1.0|
| 0.2| 2.0|
| 0.5| 2.0|
| 0.9| 2.0|
| NaN| 3.0|
| NaN| 3.0|
| NaN| 3.0|
+-----+------+
```
---
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]