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

    https://github.com/apache/spark/pull/17090#discussion_r103431594
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/recommendation/ALSSuite.scala ---
    @@ -547,6 +550,45 @@ class ALSSuite
           ALS.train(ratings)
         }
       }
    +
    +  test("recommendForAllUsers") {
    +    val numUsers = 20
    +    val numItems = 40
    +    val numRecs = 5
    +    val (training, test) = genExplicitTestData(numUsers, numItems, rank = 
2, noiseStd = 0.01)
    +    val topItems =
    +      testALS(training, test, maxIter = 4, rank = 2, regParam = 0.01, 
targetRMSE = 0.03)
    +        .recommendForAllUsers(numRecs)
    +
    +    assert(topItems.count() == numUsers)
    +    assert(topItems.columns.contains("user"))
    +    checkRecommendationOrdering(topItems, numRecs)
    +  }
    +
    +  test("recommendForAllItems") {
    +    val numUsers = 20
    +    val numItems = 40
    +    val numRecs = 5
    +    val (training, test) = genExplicitTestData(numUsers, numItems, rank = 
2, noiseStd = 0.01)
    +    val topUsers =
    +      testALS(training, test, maxIter = 4, rank = 2, regParam = 0.01, 
targetRMSE = 0.03)
    +        .recommendForAllItems(numRecs)
    +
    +    assert(topUsers.count() == numItems)
    +    assert(topUsers.columns.contains("item"))
    +    checkRecommendationOrdering(topUsers, numRecs)
    +  }
    +
    +  private def checkRecommendationOrdering(topK: DataFrame, k: Int): Unit = 
{
    +    assert(topK.columns.contains("recommendations"))
    +    topK.select("recommendations").collect().foreach(
    --- End diff --
    
    Purely a style suggestion but you can get rid of one set of parens:
    
    ```
    ...foreach { row =>
      ...
    }
    ```


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