Last active
December 23, 2015 05:59
-
-
Save predictioniogists/6590769 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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