Skip to content

Commit 6b03d82

Browse files
committed
address comments
1 parent 4be4423 commit 6b03d82

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

mllib/src/main/scala/org/apache/spark/mllib/api/python/PowerIterationClusteringModelWrapper.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ import org.apache.spark.mllib.clustering.PowerIterationClusteringModel
2626
private[python] class PowerIterationClusteringModelWrapper(model: PowerIterationClusteringModel)
2727
extends PowerIterationClusteringModel(model.k, model.assignments) {
2828

29-
def getAssignments: RDD[(Long, Int)] = {
30-
SerDe.fromTuple2RDD(model.assignments.map(x => (x.id, x.cluster)))
31-
.asInstanceOf[RDD[(Long, Int)]]
29+
def getAssignments: RDD[Array[Any]] = {
30+
model.assignments.map(x => Array(x.id, x.cluster))
3231
}
3332
}

mllib/src/main/scala/org/apache/spark/mllib/api/python/PythonMLLibAPI.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,12 @@ private[python] class PythonMLLibAPI extends Serializable {
411411
* handle to the Java object instead of the content of the Java object. Extra care
412412
* needs to be taken in the Python code to ensure it gets freed on exit; see the
413413
* Py4J documentation.
414+
* @param data an RDD of (i, j, s,,ij,,) tuples representing the affinity matrix.
415+
* @param k number of clusters.
416+
* @param maxIterations maximum number of iterations of the power iteration loop.
417+
* @param initMode the initialization mode. This can be either "random" to use
418+
* a random vector as vertex properties, or "degree" to use
419+
* normalized sum similarities. Default: random.
414420
*/
415421
def trainPowerIterationClusteringModel(
416422
data: JavaRDD[Vector],

python/pyspark/mllib/clustering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def assignments(self):
317317
Returns the cluster assignments of this model.
318318
"""
319319
return self.call("getAssignments").map(
320-
lambda x: (PowerIterationClustering.Assignment(x[0], x[1])))
320+
lambda x: (PowerIterationClustering.Assignment(*x)))
321321

322322
@classmethod
323323
def load(cls, sc, path):

0 commit comments

Comments
 (0)