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 150d26c commit f77904dCopy full SHA for f77904d
mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala
@@ -339,10 +339,14 @@ 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
- val selected = children.minBy { child =>
343
- KMeans.fastSquaredDistance(newClusterCenters(child), v)
+ if (children.length > 0) {
+ val selected = children.minBy { child =>
344
+ KMeans.fastSquaredDistance(newClusterCenters(child), v)
345
+ }
346
+ (selected, v)
347
+ } else {
348
+ (index, v)
349
}
- (selected, v)
350
} else {
351
(index, v)
352
0 commit comments