Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Modifications: Minor correction in the powerIterationSuite
  • Loading branch information
shahidki31 committed Jul 4, 2018
commit a591e4fb755df1d10255cf1d4d916a4afa604442
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,33 @@ class PowerIterationClusteringSuite extends SparkFunSuite
.setMaxIter(40)
.setWeightCol("weight")
.assignClusters(data)
.select("id", "cluster")
.as[(Long, Int)]
.collect()

val predictions = Array.fill(2)(mutable.Set.empty[Long])
assignments.select("id", "cluster").collect().foreach {
case Row(id: Long, cluster: Integer) => predictions(cluster) += id

assignments.foreach{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might fail the style checker -- need a space before the brace. Looks good otherwise. Let's see if the test passes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the space. Thank you.

case (id, cluster) => predictions(cluster) += id
}
assert(predictions.toSet == Set((0 until n1).toSet, (n1 until n).toSet))

assert(predictions.toSet === Set((0 until n1).toSet, (n1 until n).toSet))

val assignments2 = new PowerIterationClustering()
.setK(2)
.setMaxIter(10)
.setInitMode("degree")
.setWeightCol("weight")
.assignClusters(data)
.select("id", "cluster")
.as[(Long, Int)]
.collect()

val predictions2 = Array.fill(2)(mutable.Set.empty[Long])
assignments2.select("id", "cluster").collect().foreach {
case Row(id: Long, cluster: Integer) => predictions2(cluster) += id
assignments2.foreach {
case (id, cluster) => predictions2(cluster) += id
}
assert(predictions2.toSet == Set((0 until n1).toSet, (n1 until n).toSet))
assert(predictions2.toSet === Set((0 until n1).toSet, (n1 until n).toSet))
}

test("supported input types") {
Expand Down