text_plain_output_1.png
from lightfm import LightFM

from lightfm.datasets import fetch_movielens

import numpy as np

import numpy as np # linear algebra

data = fetch_movielens(min_rating=3.0)

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

def recommendation(model, data, ids):
    n_users, n_items = data['test'].shape
    for i in ids:
        pos = data['item_labels'][data['test'].tocsr()[i].indices]
        scores = model.predict(i, np.arange(n_items))
        top_items = data['item_labels'][np.argsort(-scores)]

recommendation(model_0, data, [215, 489, 116])