Github user alokob commented on a diff in the pull request:
https://github.com/apache/spark/pull/16355#discussion_r93470185
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala ---
@@ -339,10 +339,14 @@ private object BisectingKMeans extends Serializable {
assignments.map { case (index, v) =>
if (divisibleIndices.contains(index)) {
val children = Seq(leftChildIndex(index), rightChildIndex(index))
- val selected = children.minBy { child =>
- KMeans.fastSquaredDistance(newClusterCenters(child), v)
+ if (children.length > 0) {
--- End diff --
I can see following possibility to get java.util.NoSuchElementException in
the original code.
leftChildIndex(index) , this methods returns index*2 and
rightChildIndex(index) returns index*2+1. If the Map object newClusterCenters
does not have entries belonging to leftChildIndex(index) or
rightChildIndex(index) .
Here we need to have this check newClusterCenters.contains(child) , to
avoid this issue.
---
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]