-
- Downloads
[SPARK-13068][PYSPARK][ML] Type conversion for Pyspark params
## What changes were proposed in this pull request? This patch adds type conversion functionality for parameters in Pyspark. A `typeConverter` field is added to the constructor of `Param` class. This argument is a function which converts values passed to this param to the appropriate type if possible. This is beneficial so that the params can fail at set time if they are given inappropriate values, but even more so because coherent error messages are now provided when Py4J cannot cast the python type to the appropriate Java type. This patch also adds a `TypeConverters` class with factory methods for common type conversions. Most of the changes involve adding these factory type converters to existing params. The previous solution to this issue, `expectedType`, is deprecated and can be removed in 2.1.0 as discussed on the Jira. ## How was this patch tested? Unit tests were added in python/pyspark/ml/tests.py to test parameter type conversion. These tests check that values that should be convertible are converted correctly, and that the appropriate errors are thrown when invalid values are provided. Author: sethah <seth.hendrickson16@gmail.com> Closes #11663 from sethah/SPARK-13068-tc.
Showing
- python/pyspark/ml/classification.py 13 additions, 7 deletionspython/pyspark/ml/classification.py
- python/pyspark/ml/clustering.py 9 additions, 5 deletionspython/pyspark/ml/clustering.py
- python/pyspark/ml/feature.py 55 additions, 40 deletionspython/pyspark/ml/feature.py
- python/pyspark/ml/param/__init__.py 163 additions, 18 deletionspython/pyspark/ml/param/__init__.py
- python/pyspark/ml/param/_shared_params_code_gen.py 51 additions, 40 deletionspython/pyspark/ml/param/_shared_params_code_gen.py
- python/pyspark/ml/param/shared.py 29 additions, 29 deletionspython/pyspark/ml/param/shared.py
- python/pyspark/ml/recommendation.py 16 additions, 9 deletionspython/pyspark/ml/recommendation.py
- python/pyspark/ml/regression.py 16 additions, 9 deletionspython/pyspark/ml/regression.py
- python/pyspark/ml/tests.py 66 additions, 17 deletionspython/pyspark/ml/tests.py
- python/pyspark/ml/tuning.py 3 additions, 2 deletionspython/pyspark/ml/tuning.py
Loading
Please register or sign in to comment