pywFM icon indicating copy to clipboard operation
pywFM copied to clipboard

Global bias is None, even k0 is True

Open snowsteper opened this issue 7 years ago • 2 comments

I was trying to calculate the prediction value myself with the weight output by model and always got the wrong answer. Then I realized that the bias value is always None, even if I set k0=True manually.

fm = pywFM.FM(task='regression', num_iter=5, k2=2, k0=True)

I don't know whether the wrong answer came from the absence of bias, but it seems strange that the global_bias is always None.

How can I fix it? Or, is there any possibility I can calculate the prediction myself?

snowsteper avatar Feb 11 '18 08:02 snowsteper

Could you provide a MWE?

Thank you for the report!

jfloff avatar Feb 13 '18 23:02 jfloff

I had the same issue, with both regression and classification. Below is an MWE. (I followed the installation for libfm, and installed the latest pywFM with https://github.com/jfloff/pywFM/issues/29#issuecomment-663429991)

import numpy as np
import pywFM

x = np.array([
    [0., 1.],
    [1., 0.],
])
y = np.array([-1., 1.])

fm = pywFM.FM("regression", num_iter=10, k0=True, seed=1)
model = fm.run(x, y, x, y) # using the same data for simplicity
print(model.predictions, model.global_bias)
# output: [-0.429961, 0.264456] None

Not sure if the issue is due to temp files. Thanks in advance!

kevin1kevin1k avatar Aug 26 '21 03:08 kevin1kevin1k