Skip to content

Collaborative Filtering and Alternating Least Squares #139

Open

Description

@TomAugspurger

This would be fun / maybe useful to people.

ALS has a couple embarrassingly parallel stages. But getting good performance in a distributed setting requires some very careful bookkeeping about which blocks of the user and item factor matrices are required at each step. master...TomAugspurger:als does none of this bookkeeping at the moment, and is extremely slow.

I haven't found any papers about blocked ALS yet. The Spark scaladoc gives some hints: https://spark.apache.org/docs/2.2.0/api/scala/index.html#org.apache.spark.ml.recommendation.ALS

Some references

I plan to work on this for fun on nights and weekends, but if someone wants to take it up then by all means.

Activity

  1. mrocklin commented on Feb 20, 2018

    @mrocklin
    Member

    Two comments:

    1. I wonder if converting a naive numpy implementation to dask.array would work well
    2. I'm not sure if this was intentional, but in general you should avoid the use of inv. The scipy.linalg.solve function is almost always more efficient and numerically stable. In your case I suspect that the matrix to be solved is also positive definite, in which case the posdef=True keyword should be used for an additional ~2x speed increase.
  2. mrocklin commented on Feb 20, 2018

    @mrocklin
    Member

    Also, here is an approach for a multi-dimensional ALS implementation based on dask array: https://gist.github.com/mrocklin/6fc759ab829a44c4f1969a6d6fc9dd28

  3. mrocklin commented on Feb 20, 2018

    @mrocklin
    Member

    Also cc @jcrist who may be thinking about these sorts of problems in the near future.

  4. TomAugspurger commented on Feb 20, 2018

    @TomAugspurger
    MemberAuthor

    does none of this bookkeeping at the moment, and is extremely slow.

    I may have been a bit hasty with this assessment. I didn't carefully check the blocked version I wrote.

    I wonder if converting a naive numpy implementation to dask.array would work well

    I think I wrote something that did that (will search for the notebook) and things seemed OK on a toy dataset. I haven't gotten a good grasp for how important sparsity is for this kind of problem.

    but in general you should avoid the use of inv.

    👍 https://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/ I was being lazy.

  5. mrocklin commented on Feb 20, 2018

    @mrocklin
    Member

    We can also handle sparsity through improved support for sparse sub-arrays in dask array.

  6. rth commented on Feb 20, 2018

    @rth
    Contributor

    I wonder if converting a naive numpy implementation to dask.array would work well

    From the implicit readme,

    this library is about 1.8 times faster than the multithreaded C++ implementation provided by Quora's QMF Library and at least 60,000 times faster than implicit-mf.

    the latter is a numpy / scipy implementation of the original paper (though I imagine it can be optimized further)....

    Also looking at the implicit vs spark comparison I imagine it will be difficult to match or outperform implicit ALS with dask-ml on a single multi-core machine since it's hand optimized in Cython and parallized with OpenMP already. So is the aim more the distributed case?

  7. added
    Roadmap
    on Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Roadmap

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions