Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1407#discussion_r14925960
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/clustering/LocalKMeans.scala ---
    @@ -59,6 +59,11 @@ private[mllib] object LocalKMeans extends Logging {
             cumulativeScore += weights(j) * KMeans.pointCost(curCenters, 
points(j))
             j += 1
           }
    +      if (j == 0) {
    +        logWarning("kMeansPlusPlus initialization ran out of distinct 
points for centers." +
    +          s" Using duplicate point for center k = $i.")
    +        j = 1
    --- End diff --
    
    The code may be clearer if written in this way
    
    ~~~
    centers(i) = 
      if (j == 0) {
        logWarning("...")
        points(0).toDense
      } else {
        points(j - 1).toDense
      }
    ~~~
    
    or 
    
    ~~~
    if (j == 0) {
      logWarning("...")
      centers(i) = points(0).toDense
    } else {
      centers(i) = points(j - 1).toDense
    }
    ~~~


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to