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

    https://github.com/apache/spark/pull/15450#discussion_r84247187
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/clustering/KMeans.scala ---
    @@ -323,7 +324,10 @@ class KMeans private (
        * Initialize a set of cluster centers at random.
        */
       private def initRandom(data: RDD[VectorWithNorm]): Array[VectorWithNorm] 
= {
    -    data.takeSample(true, k, new 
XORShiftRandom(this.seed).nextInt()).map(_.toDense)
    +    // Select without replacement; may still produce duplicates if the 
data has < k distinct
    +    // points, so deduplicate the centroids to match the behavior of 
k-means|| in the same situation
    +    data.takeSample(false, k, new XORShiftRandom(this.seed).nextInt()).
    +      map(_.vector).distinct.map(new VectorWithNorm(_))
    --- End diff --
    
    I'll move the dot. Agree, though computing k norms once seems negligible in 
the context of the overall computation.


---
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]

Reply via email to