Spaces:
Sleeping
Sleeping
File size: 751 Bytes
af5cf7c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
from fastai.learner import Learner
import pandas as pd
def get_recommendations_for_user(learn: Learner, user_id: str, limit: int = 5):
# TODO: Fetch list of not listened songs as entries
not_listened_songs = ["Revelry, Kings of Leon, 2008", "Gears, Miss May I, 2010", "Sexy Bitch, David Guetta, 2009"]
input_dataframe = pd.DataFrame({'user_id': ["440abe26940ae9d9268157222a4a3d5735d44ed8"] * len(not_listened_songs), 'entry': not_listened_songs})
test_dl = learn.dls.test_dl(input_dataframe)
predictions = learn.get_preds(dl=test_dl)
# TODO: Return recommendations in track format
return {
"user_id": user_id,
"limit": limit,
"recommendations": predictions[0].numpy().tolist()
} |