spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mengxr <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-8765] [MLlib] Fix PySpark PowerIteratio...
Date Thu, 02 Jul 2015 04:46:15 GMT
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7177#discussion_r33747055
  
    --- Diff: python/pyspark/mllib/clustering.py ---
    @@ -282,18 +282,30 @@ class PowerIterationClusteringModel(JavaModelWrapper, JavaSaveable,
JavaLoader):
     
         Model produced by [[PowerIterationClustering]].
     
    -    >>> data = [(0, 1, 1.0), (0, 2, 1.0), (1, 3, 1.0), (2, 3, 1.0),
    -    ...     (0, 3, 1.0), (1, 2, 1.0), (0, 4, 0.1)]
    +    >>> data = [(0, 1, 1.0), (0, 2, 1.0), (0, 3, 1.0), (1, 2, 1.0), (1, 3, 1.0),
    +    ... (2, 3, 1.0), (3, 4, 0.1), (4, 5, 1.0), (4, 15, 1.0), (5, 6, 1.0),
    +    ... (6, 7, 1.0), (7, 8, 1.0), (8, 9, 1.0), (9, 10, 1.0), (10, 11, 1.0),
    +    ... (11, 12, 1.0), (12, 13, 1.0), (13, 14, 1.0), (14, 15, 1.0)]
         >>> rdd = sc.parallelize(data, 2)
         >>> model = PowerIterationClustering.train(rdd, 2, 100)
         >>> model.k
         2
    +    >>> result = sorted(model.assignments().collect(), key=lambda x: x.id)
    +    >>> sum([x.cluster != result[3].cluster for x in result if x.id < 3])
    --- End diff --
    
    The doctest also serve as example code in the generated Python doc. So we should keep
the doctest simple. It is hard to imagine a user needs this command. What was the exact issue
with the following?
    
    ~~~
    >>> sorted(model.assignments().collect(), key=lambda x: x.id)
    ~~~


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message