text_plain_output_1.png
from lightfm import LightFM

from lightfm.datasets import fetch_movielens

from lightfm.evaluation import precision_at_k,auc_score

data = fetch_movielens(min_rating=3.0)

model_0 = LightFM(loss='warp')
model_0.fit(data['train'], epochs=70, num_threads=4)

model_1 = LightFM(loss='bpr')
model_1.fit(data['train'], epochs=70, num_threads=4)

test_precision_0 = auc_score(model_0, data['test'], data['train']).mean()
test_precision_1 = auc_score(model_1, data['test'], data['train']).mean()
print(test_precision_0, test_precision_1)