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

    https://github.com/apache/spark/pull/17117#discussion_r104092773
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/clustering/KMeansSuite.scala ---
    @@ -152,6 +158,35 @@ class KMeansSuite extends SparkFunSuite with 
MLlibTestSparkContext with DefaultR
         val kmeans = new KMeans()
         testEstimatorAndModelReadWrite(kmeans, dataset, 
KMeansSuite.allParamSettings, checkModelData)
       }
    +
    +  test("training with initial model") {
    +    val kmeans = new KMeans().setK(2).setSeed(1)
    +    val model1 = kmeans.fit(rData)
    +    val model2 = 
kmeans.setInitMode("initialModel").setInitialModel(model1).fit(rData)
    +    model2.clusterCenters.zip(model1.clusterCenters)
    +      .foreach { case (center2, center1) => assert(center2 ~== center1 
absTol 1E-8) }
    +  }
    +
    +  test("training with initial model, error cases") {
    +    val kmeans = new KMeans().setK(k).setSeed(1).setMaxIter(1)
    +
    +    // Sets initMode with 'initialModel', but does not specify initial 
model.
    +    intercept[IllegalArgumentException] {
    --- End diff --
    
    I'm not sure I agree with the behavior. We discussed it quite a bit in the 
other PR - maybe you can summarize the reason you went away from the previous 
decisions? At any rate, it seems currently we have the following behavior:
    
    | k      | initMode           | initialModel  | result |
    --- | --- | --- | ---
    | ?    | not set | set | ignore InitialModel |
    | ?    | set | not set | error |
    |  set (k != initialModelK)   | set | set | error |
    |  set (k == initialModelK)   | set | set | use initialModel |
    
    If we keep this behavior, we should add a test for the first case. 


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