Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/7121#discussion_r33748863
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/recommendation/MatrixFactorizationModel.scala
---
@@ -88,12 +88,25 @@ class MatrixFactorizationModel(
* @return RDD of Ratings.
*/
def predict(usersProducts: RDD[(Int, Int)]): RDD[Rating] = {
- 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 usersCount = usersProducts.keys.countApproxDistinct()
--- End diff --
Btw, if we really want to optimize number of passes. We can copy the code
from
https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/rdd/RDD.scala#L1170
and use one pass to count both columns.
---
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]