Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6737#discussion_r32782633
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/mllib/clustering/KMeansSuite.scala ---
    @@ -278,6 +278,34 @@ class KMeansSuite extends SparkFunSuite with 
MLlibTestSparkContext {
           }
         }
       }
    +
    +  test("Initialize using given cluster centers") {
    +    val points = Seq(
    +      Vectors.dense(0.0, 0.0),
    +      Vectors.dense(0.0, 0.1),
    +      Vectors.dense(0.1, 0.0),
    +      Vectors.dense(9.0, 0.0),
    +      Vectors.dense(9.0, 0.2),
    +      Vectors.dense(9.2, 0.0)
    +    )
    +    val rdd = sc.parallelize(points, 3)
    +    val model = KMeans.train(rdd, k = 2, maxIterations = 2, runs = 1)
    +
    +    val tempDir = Utils.createTempDir()
    +    val path = tempDir.toURI.toString
    +    model.save(sc, path)
    +    val loadedModel = KMeansModel.load(sc, path)
    +
    +    val newModel = KMeans.train(rdd, k = 2, maxIterations = 2, 
initialModel = loadedModel)
    --- End diff --
    
    This seems like a somewhat brittle test.  It requires that the initial 
training find the correct centers.  I imagine it generally would, but with so 
few data, I suspect it will fail every now and then.
    
    A better test might be:
    * have 4 data points A,B,C,D at the corners of a square
    * use k = 2
    * compare the results from starting with initial centers at A,C vs. B,D, 
using maxIterations = 1
    
    (Basically, cluster centers should not move, so they should definitely be 
different in the end.)


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to