Reputation: 33
Please help! I'm trying to make a movie recommendation system.
I'm on windows using PyCharm.
I've tried installing lightfm on both PIP and Conda.
Any suggestions are welcome! I'm only a beginner.
Code:
import numpy as np
from lightfm.datasets import fetch_movielens
from lightfm import LightFM
# fetch data and format it
data = fetch_movielens(min_rating = 4.0)
# create model
model = LightFM(loss='warp')
# measures difference between model's prediction and desired output
# train model
model.fit(data['train'], epochs=30, num_threads=2)
def sample_recommendation(model,data,user_ids):
#number of users and movies in training data
n_users, n_items = data['train'].shape
for user_id in user_ids:
known_positives = data['item_labels'][data['train'].tocsr()[user_id].indices]
scores = model.predict(user_id, np.arrange(n_items))
top_items = data['item_labels'][np.argsort(-scores)]
print(" Recommended:")
for x in top_items[:3]:
print(" %s" % x)
# input 3 random user IDs
sample_recommendation(model,data,[3,25,450])
Output:
C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\lightfm\_lightfm_fast.py:9: UserWarning: LightFM was compiled without OpenMP support. Only a single thread will be used.
warnings.warn(
Process finished with exit code -1073741819 (0xC0000005)
Upvotes: 0
Views: 211