Github user dbtsai commented on a diff in the pull request:
https://github.com/apache/spark/pull/17117#discussion_r104800325
--- 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 --
My 2cents is the latter configuration should be able to overwrite the
former settings and related settings with warning messages.
In your example, when `kmeans.setInitMode("k-means||")` is performed, the
first `setInitialModel` should be ignored with warning message.
Even we do `setK(k =3)`, and later we do `.setInitialModel(initialModel)`,
we should ignore the first `setK(k =3)` with warning.
---
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]