We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f77904d commit 55ab179Copy full SHA for 55ab179
mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala
@@ -339,8 +339,9 @@ private object BisectingKMeans extends Serializable {
339
assignments.map { case (index, v) =>
340
if (divisibleIndices.contains(index)) {
341
val children = Seq(leftChildIndex(index), rightChildIndex(index))
342
- if (children.length > 0) {
343
- val selected = children.minBy { child =>
+ val newClusterChildren = children.filter(newClusterCenters.contains(_))
+ if (newClusterChildren.nonEmpty) {
344
+ val selected = newClusterChildren.minBy { child =>
345
KMeans.fastSquaredDistance(newClusterCenters(child), v)
346
}
347
(selected, v)
0 commit comments