@@ -618,8 +618,7 @@ def assignments(self):
618618 """
619619 Returns the cluster assignments of this model.
620620 """
621- return self .call ("getAssignments" ).map (
622- lambda x : (PowerIterationClustering .Assignment (* x )))
621+ return self .call ("getAssignments" ).map (lambda x : Assignment (* x ))
623622
624623 @classmethod
625624 @since ('1.5.0' )
@@ -633,6 +632,12 @@ def load(cls, sc, path):
633632 return PowerIterationClusteringModel (wrapper )
634633
635634
635+ #: Represents an (id, cluster) tuple.
636+ #:
637+ #: .. versionadded:: 1.5.0
638+ Assignment = namedtuple ("Assignment" , ["id" , "cluster" ])
639+
640+
636641class PowerIterationClustering (object ):
637642 """
638643 Power Iteration Clustering (PIC), a scalable graph clustering algorithm
@@ -671,12 +676,8 @@ def train(cls, rdd, k, maxIterations=100, initMode="random"):
671676 rdd .map (_convert_to_vector ), int (k ), int (maxIterations ), initMode )
672677 return PowerIterationClusteringModel (model )
673678
674- class Assignment (namedtuple ("Assignment" , ["id" , "cluster" ])):
675- """
676- Represents an (id, cluster) tuple.
677-
678- .. versionadded:: 1.5.0
679- """
679+ # Backward-compatible alias.
680+ Assignment = Assignment
680681
681682
682683class StreamingKMeansModel (KMeansModel ):
0 commit comments