0

I have two questions related to the LightFM model:

  1. I read the article about the model and I see that it uses sigmoid f(.)-function. I also checked library's Cython code and I see that the function is implemented there as well. However, the model is applicable to rank items in the rating setting (rating from 1 to 5). Why isn't sigmoid harming the ranking system? I mean it returns the value from 0 to 1, why the model still works for ratings?
  2. Am I correct that the scores which model returns is q_u * p_i + b_u + b_i (see the article)? If not, how can I calculate the scores myself? Where do they come from and why their magnitude is so high? I get the scores approximately from -100000 to +100000.

UPD1: I followed the comments and found out the following function:

cdef inline flt compute_prediction_from_repr(flt *user_repr,
                                             flt *item_repr,
                                             int no_components) nogil:

    cdef int i
    cdef flt result

    # Biases
    result = user_repr[no_components] + item_repr[no_components]

    # Latent factor dot product
    for i in range(no_components):
        result += user_repr[i] * item_repr[i]

    return result

It seems like the scores are indeed the formula above, but it would be helpful if someone could also have a look - I'm not very good with Cython

UPD2: sigmoid is used only for the logistic variant of the model. It's not used if you try WARP.

  • I use WARP-loss in my model and I see that the scores change with the parameters, so it seems reasonable that WARP changes them with gradient steps. However, I still don't understand why we don't have any problems with sigmoid and how scores relate to the formula. – Anna Denisova Jul 03 '22 at 19:48
  • I didn't get it too, but since it's using the sigmoid function as an objective function, then, all F(x) must be in the range [0, 1]. Can we suppose that the author is multiplying the scores by 5 since it will give values within the range [0, 5]? – aliwimo Jul 03 '22 at 20:06
  • You almost certainly want to be looking at the pyx code that goes into Cython rather than the c code that comes out. It'll be much much more readable – DavidW Jul 03 '22 at 21:05
  • @DavidW here is pyx code https://github.com/lyst/lightfm/blob/master/lightfm/_lightfm_fast.pyx.template I'm still not sure about both questions( – Anna Denisova Jul 03 '22 at 21:13

1 Answers1

0

The model works for ratings using Sigmoid because LightFM binarizes the recommendation problem.

For ratings between 1 to 5 with 5 being the highest,

  • ratings 4 and 5 indicate user interest in the item -> Positive
  • ratings from 1 to 3 indicate user not interested in the item -> Negative

This is the reason model performance is indicated using a AUC score. For an individual user, AUC corresponds to the probability that a randomly chosen positive item will be ranked higher than a randomly chosen negative item.

In my case I applied the WARP Loss and use WARP score as an indicator to closeness of the item to the user in feature space to being liked by the User. For a probabilistic score or ratings prediction other sophisticated models may be considered.