fix per product score calculation
This commit is contained in:
parent
1735ae79f7
commit
bb579f2f6f
1 changed files with 3 additions and 3 deletions
|
@ -107,15 +107,15 @@ class Engine:
|
|||
)
|
||||
videos += playlists[:channels['globalKeywords']]
|
||||
playlists = playlists[channels['globalKeywords']:]
|
||||
# Count tags for the user
|
||||
# Count products the user has seen
|
||||
count = defaultdict(lambda: 0)
|
||||
for event in user.get('events', []):
|
||||
if event.get('data', {}).get('product'):
|
||||
count[event['data']['product']] += 1
|
||||
# For each tag in playlist, increment score by count
|
||||
# For each product in playlist tags, increment score by count
|
||||
for playlist in playlists:
|
||||
score[playlist['name']] = random.random()
|
||||
for tag in [tag for tag in playlist['tags'] if tag not in sliders]:
|
||||
for tag in set(playlist['tags']) & set(count):
|
||||
score[playlist['name']] += count[tag]
|
||||
# Select highest scoring playlists
|
||||
videos += sorted(
|
||||
|
|
Loading…
Reference in a new issue