zhengruifeng commented on a change in pull request #27758: 
[SPARK-31007][ML][WIP] KMeans optimization based on triangle-inequality
URL: https://github.com/apache/spark/pull/27758#discussion_r409316055
 
 

 ##########
 File path: 
mllib/src/main/scala/org/apache/spark/mllib/clustering/DistanceMeasure.scala
 ##########
 @@ -17,23 +17,124 @@
 
 package org.apache.spark.mllib.clustering
 
+import org.apache.spark.SparkContext
 import org.apache.spark.annotation.Since
+import org.apache.spark.broadcast.Broadcast
 import org.apache.spark.mllib.linalg.{Vector, Vectors}
 import org.apache.spark.mllib.linalg.BLAS.{axpy, dot, scal}
 import org.apache.spark.mllib.util.MLUtils
 
 private[spark] abstract class DistanceMeasure extends Serializable {
 
+  /**
+   * Statistics used in triangle inequality to obtain useful bounds to find 
closest centers.
+   * @param distance distance between two centers
+   */
+  def computeStatistics(distance: Double): Double
+
+  /**
+   * Statistics used in triangle inequality to obtain useful bounds to find 
closest centers.
+   *
+   * @return A symmetric matrix containing statistics, matrix(i)(j) represents:
 
 Review comment:
   good idea, it is symmetric. I will study how other impls like GMM to store 
only the upper triangular part of the matrix.
   Maybe it is helpful to support symmetric dense matrix in .linalg? since it 
is used in many places

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to