Skip to content

Instantly share code, notes, and snippets.

@JnBrymn-EB
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JnBrymn-EB/bb3c20b0673b6479f4c0 to your computer and use it in GitHub Desktop.
Save JnBrymn-EB/bb3c20b0673b6479f4c0 to your computer and use it in GitHub Desktop.
example recommendation workflow
event_clicks = get_clicks() # reusable!
# [(user_id, guest_id, event_id),...]
event_clicks = collapse_to_person_event(event_clicks) # reusable! testable!
# [(person_id, event_id),...]
person_to_their_events = event_clicks.reduceByKey(event_clicks)
# [(person_id, [event_id,...])...]
event_sets = person_to_their_events.values()
# [[event_id,...]]
event_to_events_cooccurrence = cooccurrence(event_sets) # reusable! testable!
# [(event_id, [event_id,...])]
person_to_events_recommendations = multiply(person_to_their_events, event_to_events_cooccurrence) # reusable! testable! also, naming is tricky
# [(person_id, {event_id:weight...})...]
event_to_persons_recommendations = transpose(person_to_events_recommendations) # reusable! testable!
# [(event_id, {person_id:weight...}...]
recommended_events = event_to_persons_recommendations.keys()
# [event_id...]
put_recommended_events(recommended_events) # reusable!
put_event_to_person_recommendations(event_to_persons_recommendations) # reusable!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment