-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCFModel.py
28 lines (19 loc) · 1.15 KB
/
CFModel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Collaborative based system predicts what a particular user might like based on what other similar users like.
# Leveraging the item similarity based collaborative filtering model
is_model = Recommenders.item_similarity_recommender_py()
is_model.create(train_data, 'user_id', 'song')
#Print the songs for the user in training data
user_id = users[5]
user_items = is_model.get_user_items(user_id)
#print("------------------------------------------------------------------------------------")
print("Training data songs for the user userid: %s:" % user_id)
print("------------------------------------------------------------------------------------")
for user_item in user_items:
print(user_item)
print("----------------------------------------------------------------------")
print("Recommendation process going on:")
print("----------------------------------------------------------------------")
#Recommend songs for the user using personalized model
is_model.recommend(user_id)
# We can also use our item similarity based collaborative filtering model to find similar songs to any songs in our dataset:
is_model.get_similar_items(['U Smile - Justin Bieber'])