Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/7121#discussion_r33565698
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/recommendation/MatrixFactorizationModel.scala
---
@@ -89,10 +89,14 @@ class MatrixFactorizationModel(
*/
def predict(usersProducts: RDD[(Int, Int)]): RDD[Rating] = {
val users = userFeatures.join(usersProducts).map {
- case (user, (uFeatures, product)) => (product, (user, uFeatures))
+ case (user, (uFeatures, product)) => ((user, product), uFeatures)
}
- users.join(productFeatures).map {
- case (product, ((user, uFeatures), pFeatures)) =>
+ val productUsers = usersProducts.map(up => (up._2, up._1))
+ val products = productFeatures.join(productUsers).map {
--- End diff --
Hm, I wonder if it's feasible to turn this computation around on join on
product then user if the number of users is bigger (i.e. if there are more
users than products)? I haven't thought it through fully but that may avoid
another join + bigger join. Also you should be able to swap tuples with
`_.swap`
---
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]