Kazuki Yokoishi created SPARK-15243: ---------------------------------------
Summary: 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 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.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org