jfloff / pywFM

pywFM is a Python wrapper for Steffen Rendle's factorization machines library libFM
https://pypi.python.org/pypi/pywFM
MIT License
250 stars 43 forks source link

problem of regression results #19

Closed kkhuang1990 closed 7 years ago

kkhuang1990 commented 7 years ago

I ran your example code as follows

import pywFM import numpy as np import pandas as pd

features = np.matrix([

[1, 0, 0,  1,  0,  0,  0,   0.3, 0.3, 0.3, 0,     13,   0,  0,  0,  0 ],
[1, 0, 0,  0,  1,  0,  0,   0.3, 0.3, 0.3, 0,     14,   1,  0,  0,  0 ],
[1, 0, 0,  0,  0,  1,  0,   0.3, 0.3, 0.3, 0,     16,   0,  1,  0,  0 ],
[0, 1, 0,  0,  0,  1,  0,   0,   0,   0.5, 0.5,   5,    0,  0,  0,  0 ],
[0, 1, 0,  0,  0,  0,  1,   0,   0,   0.5, 0.5,   8,    0,  0,  1,  0 ],
[0, 0, 1,  1,  0,  0,  0,   0.5, 0,   0.5, 0,     9,    0,  0,  0,  0 ],
[0, 0, 1,  0,  0,  1,  0,   0.5, 0,   0.5, 0,     12,   1,  0,  0,  0 ]

]) target = [5, 3, 1, 4, 5, 1, 5]

fm = pywFM.FM(task='regression', num_iter=1000, verbose=True)

model = fm.run(features[:5], target[:5], features[5:], target[5:]) print(model.predictions) print(model.weights)

and the predictions are not so good, like this: [3.71942, 3.4779] [-0.36734, -1.25636, 1.04973, -2.0381, -2.07228, 0.0822247, -0.202202, -1.26609, -2.40143, -0.568957, -2.13888, -1.41459, 0.36015, 0.787539, -0.303377] actually the GT is [1, 5]. I tried to implement with even more iterations and the result is still not so good. how about the result of your implementation.

thx

jfloff commented 7 years ago

I didn't understand what's the problem with the predictions - that's a correct result given the amount of train/test samples. I'm using 5 training samples and 2 test which are being predicted as 3.71 and 3.47.

What's the result that you were expecting?

PS: Kindly reminder that these are the results that libfm outputs. This repo is just a wrapper.

jfloff commented 7 years ago

Closing since it just seems a misinterpretation of the expected results. Reopen if you have any problems.