Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Recommender(object):
- def get_product_key(self, id):
- return 'product:{}:purchased_with'.format(id)
- def products_bought(self, products):
- product_ids = [p.id for p in products]
- for product_id in product_ids:
- for with_id in product_ids:
- if product_id != with_id:
- r.zincrby(self.get_product_key(product_id),
- with_id,
- amount=1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement