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

    https://github.com/apache/spark/pull/3098#discussion_r27707367
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/recommendation/MatrixFactorizationModel.scala
 ---
    @@ -70,26 +71,28 @@ class MatrixFactorizationModel(
     
       /** Predict the rating of one user for one product. */
       def predict(user: Int, product: Int): Double = {
    -    val userVector = userFeatures.lookup(user).head
    -    val productVector = productFeatures.lookup(product).head
    -    blas.ddot(userVector.length, userVector, 1, productVector, 1)
    +    val userVector = Vectors.dense(userFeatures.lookup(user).head)
    +    val productVector = Vectors.dense(productFeatures.lookup(product).head)
    +    BLAS.dot(userVector, productVector)
       }
     
       /**
    -    * Predict the rating of many users for many products.
    -    * The output RDD has an element per each element in the input RDD 
(including all duplicates)
    -    * unless a user or product is missing in the training set.
    -    *
    -    * @param usersProducts  RDD of (user, product) pairs.
    -    * @return RDD of Ratings.
    -    */
    +   * Predict the rating of many users for many products.
    +   * The output RDD has an element per each element in the input RDD 
(including all duplicates)
    +   * unless a user or product is missing in the training set.
    +   *
    +   * @param usersProducts  RDD of (user, product) pairs.
    +   * @return RDD of Ratings.
    +   */
       def predict(usersProducts: RDD[(Int, Int)]): RDD[Rating] = {
    -    val users = userFeatures.join(usersProducts).map{
    +    val users = userFeatures.join(usersProducts).map {
           case (user, (uFeatures, product)) => (product, (user, uFeatures))
         }
         users.join(productFeatures).map {
           case (product, ((user, uFeatures), pFeatures)) =>
    -        Rating(user, product, blas.ddot(uFeatures.length, uFeatures, 1, 
pFeatures, 1))
    +        val userVector = Vectors.dense(uFeatures)
    +        val productVector = Vectors.dense(pFeatures)
    +        Rating(user, product, BLAS.dot(userVector, productVector))
    --- End diff --
    
    Same here,


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

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

Reply via email to