Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4564#discussion_r24707888
  
    --- Diff: python/pyspark/ml/feature.py ---
    @@ -29,18 +29,45 @@ class Tokenizer(JavaTransformer, HasInputCol, 
HasOutputCol):
         splits it by white spaces.
     
         >>> from pyspark.sql import Row
    -    >>> dataset = sqlCtx.inferSchema(sc.parallelize([Row(text="a b c")]))
    -    >>> tokenizer = Tokenizer() \
    -            .setInputCol("text") \
    -            .setOutputCol("words")
    -    >>> print tokenizer.transform(dataset).head()
    +    >>> df = sqlCtx.inferSchema(sc.parallelize([Row(text="a b c")]))
    +    >>> tokenizer = Tokenizer(inputCol="text", outputCol="words")
    +    >>> print tokenizer.transform(df).head()
         Row(text=u'a b c', words=[u'a', u'b', u'c'])
    -    >>> print tokenizer.transform(dataset, {tokenizer.outputCol: 
"tokens"}).head()
    +    >>> # Change a parameter.
    +    >>> print tokenizer.setParams(outputCol="tokens").transform(df).head()
         Row(text=u'a b c', tokens=[u'a', u'b', u'c'])
    +    >>> # Temporarily modify a parameter.
    +    >>> print tokenizer.transform(df, {tokenizer.outputCol: 
"words"}).head()
    +    Row(text=u'a b c', words=[u'a', u'b', u'c'])
    +    >>> print tokenizer.transform(df).head()
    +    Row(text=u'a b c', tokens=[u'a', u'b', u'c'])
    +    >>> # Must use keyword arguments to specify params.
    +    >>> tokenizer.setParams("text")
    +    Traceback (most recent call last):
    +        ...
    +    TypeError: Method setParams forces keyword arguments.
         """
     
         _java_class = "org.apache.spark.ml.feature.Tokenizer"
     
    +    @keyword_only
    +    def __init__(self, inputCol="input", outputCol="output"):
    --- End diff --
    
    It may cause troubles in other parameters that specify column names, for 
example `featuresCol` and `labelCol`. This is not part of this PR.


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