Skip to content

ddoeunn/Weighted-Regularized-Matrix-Factorization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weighted-Regularized-Matrix-Factorization

Weighted Regularized Matrix Factorization for Implicit Feedback in Recommender System

  • [1] Hu, Yifan, Yehuda Koren, and Chris Volinsky. "Collaborative filtering for implicit feedback datasets." 2008.
  • [2] Pan, Rong, et al. "One-class collaborative filtering." 2008.
  • [3] He, Xiangnan, et al. "Fast matrix factorization for online recommendation with implicit feedback." 2016.

I implemented WRMF methods in python in reference to Cornac. Only uniform weighting strategy on positive or negative instances is available in WMF model in Cornac. By modifying the WMF code of Cornac, I implemented user-oriented, item-oriented weighting strategy of "One-class collaborative filtering (Pan, Rong, et al.)" and item-popularity weighting strategy of "Fast matrix factorization for online recommendation with implicit feedback (He, Xiangnan, et al)".

See the example comparing weighting strategies.

Data Strategy k Train time (s) Precision@k Recall@k NDCG@k
movielens100k uniform_pos 10 6.2740 0.292365 0.184272 0.343978
movielens100k uniform_neg 10 9.2785 0.327253 0.215326 0.383740
movielens100k user_oriented 10 10.6478 0.366172 0.230124 0.431030
movielens100k item_oriented 10 9.8481 0.361082 0.229981 0.426998
movielens100k item_popularity 10 11.0064 0.360551 0.231452 0.423511
from Datasets import Movielens
from Evaluation.data_split import split_data
from Evaluation.ranking_metrics import *
from WRMF.wrmf import *
from WRMF import wrmf_rec

df_movielens = Movielens.load_data()                # load dataset
train, test = split_data(df_movielens,
                         split_strategy="random_by_user",
                         random_state=0)            # split data

wrmf = WRMF(train, weight_strategy="uniform_pos")   # wrmf model
model =  train_cornac(wrmf, train)                  # train model

k = 10
top_k = wrmf_rec.recommend_top_k(model, train, k)   # recommendation
ranking_metrics(top_k, test)                        # evaluation


Weighted Regularized Matrix Factorization (WRMF)

Basic idea of Weighted Regularized Matrix Factorization (WRMF) is to assign smaller weights to the unobserved instances than the observed. The weights are related to the concept of confidence. As not interacting with an item can result from other reasons than not liking it, negative instances have low confidence. For example, a user might be unaware of the existence of the item, or unable to consume it due to its price or limited availability. Unobserved instances are a mixture of negative and unknown feedback.

Also, interacting with an item can be caused by a variety of reasons that differ from liking it. For example, a user may buy an item as gift for someone else, despite the user does not like the item. Thus it can be thought that there are also different confidence levels among the items that the user interacted with.

Several weighting strategies have been proposed. Read more here! for more details.