You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/01/25 04:56:39 UTC

[GitHub] [spark] zhengruifeng commented on a change in pull request #31313: [SPARK-34220][ML] BucketedRandomProjectionLSH transform opt

zhengruifeng commented on a change in pull request #31313:
URL: https://github.com/apache/spark/pull/31313#discussion_r563463265



##########
File path: mllib/src/main/scala/org/apache/spark/ml/feature/BucketedRandomProjectionLSH.scala
##########
@@ -60,14 +59,20 @@ private[ml] trait BucketedRandomProjectionLSHParams extends Params {
  * where `r_i` is the i-th random unit vector. The number of buckets will be `(max L2 norm of input
  * vectors) / bucketLength`.
  *
- * @param randUnitVectors An array of random unit vectors. Each vector represents a hash function.
+ * @param randMatrix A matrix with each row representing a hash function.
  */
 @Since("2.1.0")
 class BucketedRandomProjectionLSHModel private[ml](
     override val uid: String,
-    private[ml] val randUnitVectors: Array[Vector])
+    private[ml] val randMatrix: Matrix)
   extends LSHModel[BucketedRandomProjectionLSHModel] with BucketedRandomProjectionLSHParams {
 
+  private[ml] def this(uid: String, randUnitVectors: Array[Vector]) = {
+    this(uid, Matrices.fromVectors(randUnitVectors))
+  }
+
+  private[ml] def randUnitVectors: Array[Vector] = randMatrix.rowIter.toArray

Review comment:
       add this constructor and method `randUnitVectors` for existing testsuites




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org