Saturday, July 4, 2015

LibFM in python

LibFM is library for factorization machines using an approach proposed by Steffen Rendle. However it seems that there is no python wrapper for this famous library.

However, if you're looking for python version of it, take a look at these projects:

Update: I've tested some LibFM implementations on several datasets. I included libFM and options proposed in this post.
  • https://github.com/coreylynch/pyFM
    Lovely minimalistic implementation of Factorization Machines using cython (previous version used numpy).
    This library has an interface similar to scikit-learn.
  • http://ibayer.github.io/fastFM/index.html
    fastFM is another option. Library supports both classification and regression.
    Contains three different solvers (SGD, ALS, MCMC). ALS = alternative least squares.
    In the paper written by author of algorithm, he argues that other algorithms are comparable to SGD.

    This library is completely following scikit-learn interface (even deriving from BaseEstimator and appropriate mixin classes).
  • I was also looking for code in theano, but the only code I found was very dirty and minimalistic (so I'm not hoping it is usable)
    https://github.com/instagibbs/FactorizationMachine

3 comments :

João Loff said...

Faced with some issues with existing libraries, I just built a python wrapper around libFM: https://github.com/jfloff/pywFM

Alex said...

Hi, Joao,
thanks for posting link.

I've looked through you repo.
I'm using the same approach now (skearn's dump_svm_light + calling libFM).
This takes 5 lines and does not require wrapper :)

Good thing about your wrapper is tha tit is able to get biases + interactions from LibFM.
Does this work with mcmc?

João Loff said...

Yes, you can get that data. Good thing about the wrapper is that you also have the output converted so you can easily use it in iterations :)

Glad you liked the repo!

Cheers