srowen commented on a change in pull request #21627: [SPARK-24484][MLLIB]Power 
Iteration Clustering is giving incorrect clustering results when there are 
mutiple leading eigen values.
URL: https://github.com/apache/spark/pull/21627#discussion_r249507314
 
 

 ##########
 File path: 
mllib/src/test/scala/org/apache/spark/ml/clustering/PowerIterationClusteringSuite.scala
 ##########
 @@ -169,6 +169,59 @@ class PowerIterationClusteringSuite extends SparkFunSuite
     assert(localAssignments === localAssignments2)
   }
 
+  test("Power Iteration failed to converge") {
+    /*
+         Graph:
+            1
+           /
+          /
+         0      2 -- 3
+     */
+    val data1 = spark.createDataFrame(Seq(
+      (0, 1),
+      (2, 3)
+    )).toDF("src", "dst")
+
+    val msg1 = intercept[SparkException] {
+      new PowerIterationClustering()
+        .setInitMode("random")
+        .setK(2)
+        .assignClusters(data1)
+    }.getMessage
+    assert(msg1.contains("Power Iteration fail to converge"))
 
 Review comment:
   Is there anything else you can assert about the model to find that it didn't 
converge, rather than catch the exception? I agree we can't test for log 
messages. It could be fine to just assert that this produces some valid answer 
in a case like this, as a test, if it does not throw an exception.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to