Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save predictioniogists/6590769 to your computer and use it in GitHub Desktop.
Save predictioniogists/6590769 to your computer and use it in GitHub Desktop.
# You need to specify the name of the engine from which you want to retrieve the prediction results.
# Add the following code to display recommended meals to the user after the user has logged in:
begin
# Retrieve top 5 recommended meals from the item recommendation engine.
# Assuming client.identify("user id") is already called when the user logged in.
iids = client.get_itemrec_top_n("the engine name", 5) # list of recommended meal IDs
rescue ItemRecNotFoundError => e
iids = get_default_iids_list(5) # default behavior when there is no prediction result, e.g. recommends newest meals
log_error(e) # log the error for debugging or analysis later
end
display_meals(iids) # display meals to the user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment