Github user sethah commented on a diff in the pull request:
https://github.com/apache/spark/pull/15450#discussion_r84775879
--- Diff:
mllib/src/test/scala/org/apache/spark/mllib/clustering/KMeansSuite.scala ---
@@ -64,18 +64,34 @@ class KMeansSuite extends SparkFunSuite with
MLlibTestSparkContext {
assert(model.clusterCenters.head ~== center absTol 1E-5)
}
- test("no distinct points") {
+ test("fewer distinct points than clusters") {
val data = sc.parallelize(
Array(
Vectors.dense(1.0, 2.0, 3.0),
Vectors.dense(1.0, 2.0, 3.0),
Vectors.dense(1.0, 2.0, 3.0)),
2)
- val center = Vectors.dense(1.0, 2.0, 3.0)
- // Make sure code runs.
- var model = KMeans.train(data, k = 2, maxIterations = 1)
- assert(model.clusterCenters.size === 2)
+ var model = KMeans.train(data, k = 2, maxIterations = 1,
initializationMode = "random")
+ assert(model.clusterCenters.length === 1)
+
+ model = KMeans.train(data, k = 2, maxIterations = 1,
initializationMode = "k-means||")
+ assert(model.clusterCenters.length === 1)
+ }
+
+
+ test("fewer clusters than points") {
--- End diff --
I'd prefer to remove these two tests since we've added a more thorough test
below. We can check the "random" init method in that test as well, then we can
eliminate these two.
---
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]