fastFM icon indicating copy to clipboard operation
fastFM copied to clipboard

Support dense matrices or convert to sparse instead of raising TypeError

Open macks22 opened this issue 8 years ago • 1 comments

When I try to fit als.FMClassifier with a dense numpy matrix, I get:

  File "/home/mack/anaconda2/lib/python2.7/site-packages/fastFM/als.py", line 175, in fit
    order="F")
  File "/home/mack/anaconda2/lib/python2.7/site-packages/fastFM/validation.py", line 29, in wrapper
    raise TypeError('A dense matrix was passed in, but sparse'
TypeError: A dense matrix was passed in, but sparsedata is required.

Any reason not to support dense matrices? I'm wondering if it's simply because the type of data an FM is well-suited for cannot generally be represented by a dense matrix. Seems like if the user can fit it into memory, then why not support it? If sparse matrices are absolutely required, is it reasonable to simply convert to a dense matrix instead of raising the TypeError?

macks22 avatar May 01 '17 21:05 macks22

FMs can deal with dense matrices but I wouldn’t expect better performance then a straight forward second order polynomial regression/classification.

The fastFM solver are optimized for sparse matrices, converting a dense matrix is conceivable but only if we raise a warning. I consider the use of dense matrices with FMs an edge case and the user should be aware of this.

ibayer avatar May 02 '17 05:05 ibayer