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

    https://github.com/apache/spark/pull/17117#discussion_r104924893
  
    --- 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 think we can not override param in any ```set***``` function, see reason 
at [here](https://github.com/apache/spark/pull/17117#discussion_r104922364). 
This is why I didn't follow the idea of previous PR. If we prefer the previous 
way, we must to handle override in ```fit``` function, I'll update following 
this idea tomorrow.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to