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

    https://github.com/apache/spark/pull/11119#discussion_r52282898
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/clustering/KMeansSuite.scala ---
    @@ -106,6 +106,38 @@ 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 points = Array(
    +      Vectors.dense(0.0, 0.0, 0.0),
    +      Vectors.dense(1.0, 1.0, 1.0),
    +      Vectors.dense(2.0, 2.0, 2.0),
    +      Vectors.dense(3.0, 3.0, 3.0),
    +      Vectors.dense(4.0, 4.0, 4.0)
    +    )
    +
    +    // creating an initial model
    +    val initialModel = new KMeansModel("test model", new 
MLlibKMeansModel(points))
    +
    +    val predictionColName = "kmeans_prediction"
    +    val kmeans = new KMeans()
    +      .setK(k)
    +      .setPredictionCol(predictionColName)
    +      .setSeed(1)
    +      .setInitialModel(initialModel)
    +    val model = kmeans.fit(dataset)
    +    assert(model.clusterCenters.length === k)
    +
    --- End diff --
    
    Maybe we can train a model here, and use it as initalModel. Since it's 
already converged, you should see that the next training will take only 1 
iteration to converge.


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