You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "holdenk (JIRA)" <ji...@apache.org> on 2017/09/08 18:59:00 UTC

[jira] [Assigned] (SPARK-15243) Binarizer.explainParam(u"...") raises ValueError

     [ https://issues.apache.org/jira/browse/SPARK-15243?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

holdenk reassigned SPARK-15243:
-------------------------------

    Assignee: Hyukjin Kwon  (was: Seth Hendrickson)

> Binarizer.explainParam(u"...") raises ValueError
> ------------------------------------------------
>
>                 Key: SPARK-15243
>                 URL: https://issues.apache.org/jira/browse/SPARK-15243
>             Project: Spark
>          Issue Type: Bug
>          Components: PySpark
>    Affects Versions: 2.0.0
>         Environment: CentOS 7, Spark 1.6.0
>            Reporter: Kazuki Yokoishi
>            Assignee: Hyukjin Kwon
>            Priority: Minor
>
> When unicode is passed to Binarizer.explainParam(), ValueError occurs.
> To reproduce:
> {noformat}
> >>> binarizer = Binarizer(threshold=1.0, inputCol="values", outputCol="features")
> >>> binarizer.explainParam("threshold") # str can be passed
> 'threshold: threshold in binary classification prediction, in range [0, 1] (default: 0.0, current: 1.0)'
> >>> binarizer.explainParam(u"threshold") # unicode cannot be passed
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)
> <ipython-input-23-01c1345db0bd> in <module>()
> ----> 1 binarizer.explainParam(u"threshold")
> /usr/spark/current/python/pyspark/ml/param/__init__.py in explainParam(self, param)
>      96         default value and user-supplied value in a string.
>      97         """
> ---> 98         param = self._resolveParam(param)
>      99         values = []
>     100         if self.isDefined(param):
> /usr/spark/current/python/pyspark/ml/param/__init__.py in _resolveParam(self, param)
>     231             return self.getParam(param)
>     232         else:
> --> 233             raise ValueError("Cannot resolve %r as a param." % param)
>     234 
>     235     @staticmethod
> ValueError: Cannot resolve u'threshold' as a param.
> {noformat}
> Same erros occur in other methods.
> * Binarizer.hasDefault()
> * Binarizer.getOrDefault()
> * Binarizer.isSet()
> These errors are caused by checks *isinstance(obj, str)* in pyspark.ml.param.Params._resolveParam().
> basestring should be used instead of str in isinstance() for backward compatibility as below.
> {noformat}
> if sys.version >= '3':
>      basestring = str
> if isinstance(obj, basestring):
>     # TODO
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org