Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/7177#discussion_r33801504
--- 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 --
You can use `...` in the output. I think the cluster assignments should be
deterministic subject to numerical difference.
---
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]