MaurizioFD / RecSys_Course_AT_PoliMi

⚠️ [ARCHIVED] This version has been archived as of october 2024 and will not be updated anymore, please refer to the README for a link to the new version. This is the official repository for the Recommender Systems course at Politecnico di Milano.
GNU Affero General Public License v3.0
359 stars 146 forks source link

Question about SLIM MSE #22

Open myui opened 5 days ago

myui commented 5 days ago

Hi @MaurizioFD ,

thanks sharing an interesting recsys course materials!

I have question about SLIM MSE in https://github.com/MaurizioFD/RecSys_Course_AT_PoliMi/blob/master/Practice%2006%20-%20SLIM%20MSE%20with%20Gradient%20Descent%20and%20Cython.ipynb

It describes

Which item similarities we modify? Only those we used to compute the prediction, i.e., only the items in the profile of the sampled user.

and only user interacted item weight is updated in your implementation. Is this implementation correct?

            # Compute prediction
            start_profile = URM_train_indptr[user_id]
            end_profile = URM_train_indptr[user_id+1]

            # Update model, in this case the similarity
            for index in range(start_profile, end_profile):
                profile_item_id = URM_train_indices[index]
                profile_rating = URM_train_data[index]
                item_item_S[profile_item_id,item_id] += learning_rate * (prediction_error * profile_rating - 
                                                                         regularization_2 * item_item_S[profile_item_id,item_id])
           item_item_S[item_id,item_id] = 0.0
user item rating
u1 i1 5.0
u1 i2 2.0
u1 i3 3.0
u2 i1 4.0

i3, i2 should similar be i1 as user a interacted with i2 and i3 along with i1. However, user B does not interacted other item to i1, no updates is being done with this scheme. ~Also, only (i1, i2), (i1,i3), (i2,i3) is updated for item_item_S and similarity like (3,1) is not updated.~ (i2,i1),(i3,i1),(i3,i2) is also updated.

The original SLIM paper and it's implementation uses kNN not to update all.

MyMediaLite and LibRec optimized to use kNN in training while it's coordinate descent though.

myui commented 4 days ago

when avoiding regularization term, no user-item interaction in URM (ratings_in_user_profile=0) gives item_item_S[profile_item_id,item_id] = 0 and thus skipping (?).

    # Update model, in this case the similarity
    items_in_user_profile = URM_train.indices[URM_train.indptr[user_id]:URM_train.indptr[user_id+1]]
    ratings_in_user_profile = URM_train.data[URM_train.indptr[user_id]:URM_train.indptr[user_id+1]]
    item_item_S[items_in_user_profile,item_id] += learning_rate * (prediction_error * ratings_in_user_profile -
                                                                   regularization_2 * item_item_S[items_in_user_profile,item_id])