This is an automated email from the ASF dual-hosted git repository.

gurwls223 pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 95fb780f03c [SPARK-38816][ML][DOCS] Fix comment about choice of 
initial factors in ALS
95fb780f03c is described below

commit 95fb780f03cc61eda4e4e63c28a501fc69528cce
Author: Sean Owen <[email protected]>
AuthorDate: Mon Apr 18 08:54:45 2022 +0900

    [SPARK-38816][ML][DOCS] Fix comment about choice of initial factors in ALS
    
    ### What changes were proposed in this pull request?
    
    Change a comment in ALS code to match impl. The comment refers to taking 
the absolute value of a Normal(0,1) value, but it doesn't.
    
    ### Why are the changes needed?
    
    The docs and impl are inconsistent. The current behavior actually seems 
fine, desirable, so, change the comments.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Existing tests
    
    Closes #36228 from srowen/SPARK-38816.
    
    Authored-by: Sean Owen <[email protected]>
    Signed-off-by: Hyukjin Kwon <[email protected]>
    (cherry picked from commit b2b350b1566b8b45c6dba2f79ccbc2dc4e95816d)
    Signed-off-by: Hyukjin Kwon <[email protected]>
---
 mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala 
b/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala
index 088f6a682be..c08325532dd 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala
@@ -1255,9 +1255,8 @@ object ALS extends DefaultParamsReadable[ALS] with 
Logging {
       inBlocks: RDD[(Int, InBlock[ID])],
       rank: Int,
       seed: Long): RDD[(Int, FactorBlock)] = {
-    // Choose a unit vector uniformly at random from the unit sphere, but from 
the
-    // "first quadrant" where all elements are nonnegative. This can be done 
by choosing
-    // elements distributed as Normal(0,1) and taking the absolute value, and 
then normalizing.
+    // Choose a unit vector uniformly at random from the unit sphere. This can 
be done by choosing
+    // elements distributed as Normal(0,1), and then normalizing.
     // This appears to create factorizations that have a slightly better 
reconstruction
     // (<1%) compared picking elements uniformly at random in [0,1].
     inBlocks.mapPartitions({ iter =>


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

Reply via email to