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

    https://github.com/apache/spark/pull/11119#discussion_r55967102
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/clustering/KMeansSuite.scala ---
    @@ -108,6 +113,21 @@ class KMeansSuite extends SparkFunSuite with 
MLlibTestSparkContext with DefaultR
         val kmeans = new KMeans()
         testEstimatorAndModelReadWrite(kmeans, dataset, 
KMeansSuite.allParamSettings, checkModelData)
       }
    +
    +  test("Initialize using given cluster centers") {
    +    val kmeans = new KMeans()
    +      .setK(k)
    +      .setSeed(1)
    +      .setInitialModel(initialModel)
    +    val model = kmeans.fit(dataset)
    +
    +    // Converged initial model should lead to only a single iteration.
    +    val convergedModel = 
kmeans.setInitialModel(model).fit(dataset).clusterCenters
    +    val oneIterationModel = 
kmeans.setInitialModel(model).setMaxIter(1).fit(dataset).clusterCenters
    --- End diff --
    
    Maybe what we should check it that with `setMaxIter` high values, the 
algorithm only use one iteration to converge. 
    
    Also, nicer to have another test which is 
    
    ```
    val almostConvergedModel = 
kmeans.setInitialModel(initialModel).setMaxIter(5).fit(dataset).clusterCenters
    ```
    
    And then use it to train another k-means which should significantly reduce 
the # of iteration without warn start. 


---
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