GitHub user viirya opened a pull request:

    https://github.com/apache/spark/pull/7121

    [SPARK-8708][MLlib] Paritition ALS ratings based on both users and products

    JIRA: https://issues.apache.org/jira/browse/SPARK-8708
    
    Previously the partitions of ratings are only based on the given products. 
So if the `usersProducts` given for prediction contains only few products or 
even one product, the generated ratings will be pushed into few or single 
partition and can't use high parallelism.
    
    The following codes are the example reported in the JIRA. Because it asks 
the predictions for users on product 2. There is only one partition in the 
result.
    
        >>> r1 = (1, 1, 1.0)
        >>> r2 = (1, 2, 2.0)
        >>> r3 = (2, 1, 2.0)
        >>> r4 = (2, 2, 2.0)
        >>> r5 = (3, 1, 1.0)
        >>> ratings = sc.parallelize([r1, r2, r3, r4, r5], 5)
        >>> users = ratings.map(itemgetter(0)).distinct()
        >>> model = ALS.trainImplicit(ratings, 1, seed=10)
        >>> predictions_for_2 = model.predictAll(users.map(lambda u: (u, 2)))
        >>> predictions_for_2.glom().map(len).collect()
        [0, 0, 3, 0, 0]
    
    This PR uses user and product instead of only product to partition the 
ratings.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/viirya/spark-1 mfm_fix_partition

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/7121.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #7121
    
----
commit b534dc899c908be3622cf9b61da902babd8a8f90
Author: Liang-Chi Hsieh <[email protected]>
Date:   2015-06-30T10:00:51Z

    Paritition ratings based on both users and products.

----


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