This is an old revision of the document!
Introduction
Product recommendations are usually implemented by using collaborative filtering technique which recommends items by calculating similar items to the given item as well as finding similar users to whom recommendations are being made. This is very useful algorithm and is core of many big companies like amazon,netflix etc. But the major concern with collaborative filtering is that it doesn’t handle cold start problem(eg: If user has no enrollments) well so to handle this case we need content based filtering which suggests items based on user profile.So ideally a hybrid recommendation system which implements both collaborative and content based filtering systems is required. Lightfm is the library which implements the hybrid recommendation systems.
LIGHTFM Advantages
Lightfm is a python library which implements number of popular recommendation algorithms for both implicit and explicit feedback, including efficient implementation of BPR and WARP ranking losses.It also makes it possible to incorporate both item and user metadata into the traditional matrix factorization algorithms. It has following advantages over other libraries:
It provides recommendations for both implicit and explicit data where as many other libraries support only explicit data.
It provides a facility to track metrics like model accuracy,precision which is very helpful to understand the recommendation accuracy.
It can make recommendation by considering the user and item features data.
Implementation
Lightfm is a popular recommendation algorithms for both implicit and explicit feedback data.It incorporates both item and user metadata into the traditional matrix factorization algorithms. It represents each user and item as the sum of the latent representations of their features, thus allowing recommendations to generalise to new items (via item features) and to new users (via user features).Lightfm implementation is very easy and has enough documentation in the below link
http://lyst.github.io/lightfm/docs/home.html.
Lightfm implementation can be divided into following steps
prepare interactions,user and item features matrices.
Train model with the available data.
predict results using the trained model.
1)Preparing data matrices:
dataset.fit(users=(x.user_id for x in user_rows), items=(x.course_id for x in item_rows), user_features=([x.city,x.job_role,x.org_id] for x in user_rows)).
(interactions,weights) = dataset.build_interactions(data=([x.user_id,x.course_id] for x in enrollment_rows))
user_features = dataset.build_user_features
1)