Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save predictioniogists/7093245 to your computer and use it in GitHub Desktop.
Save predictioniogists/7093245 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 provide personalized recommendation to the user after the user has logged in:
try:
# Retrieve top 10 recommnded projects from the item recommendation engine.
# Assuming client.identify("user id") is already called when the user logged in.
result = client.get_itemrec_topn("itemrec engine name", 10)
iids = result['pio_iids'] # list of recommended project IDs
except Exception as e:
iids = get_default_iids_list(10) # default behavior when no prediction results. eg. recommends the latest created projects
log_error(e) # Handle error here. You may log the error for debugging.
display_projects(iids) # display the projects to the user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment