GitHub user sethah opened a pull request:

    https://github.com/apache/spark/pull/10962

    [SPARK-13047][PYSPARK][ML] Pyspark Params.hasParam should not throw an error

    Pyspark Params class has a method `hasParam(paramName)` which returns 
`True` if the class has a parameter by that name, but throws an 
`AttributeError` otherwise. There is not currently a way of getting a Boolean 
to indicate if a class has a parameter. With Spark 2.0 we could modify the 
existing behavior of `hasParam` or add an additional method with this 
functionality.
    
    In Python:
    ```python
    from pyspark.ml.classification import NaiveBayes
    nb = NaiveBayes(smoothing=0.5)
    print nb.hasParam("smoothing")
    print nb.hasParam("notAParam")
    ```
    produces:
    > True
    > AttributeError: 'NaiveBayes' object has no attribute 'notAParam'
    
    However, in Scala:
    ```scala
    import org.apache.spark.ml.classification.NaiveBayes
    val nb  = new NaiveBayes()
    nb.hasParam("smoothing")
    nb.hasParam("notAParam")
    ```
    produces:
    > true
    > false

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/sethah/spark SPARK-13047

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/10962.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #10962
    
----
commit d52b1de1adefedb6938130d0530ea46fdb3f64f7
Author: sethah <[email protected]>
Date:   2016-01-27T23:55:04Z

    hasParam returns False instead of throwing an error

----


---
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