Skip to content
Snippets Groups Projects
Commit 4618e1c4 authored by ale's avatar ale
Browse files

remove last_song from the total for normalization too

parent 0c15ef55
No related branches found
No related tags found
No related merge requests found
......@@ -53,17 +53,21 @@ class MarkovModel(object):
def normalize(self):
norm_map = {}
for key, target_map in self._map.iteritems():
# We will explicitly drop this target to avoid repeating
# the same song more than once.
last_song = key[-1]
norm_vec = []
tot = sum(target_map.itervalues())
cur = 0
tot = cur = 0
for target, count in target_map.iteritems():
# We explicitly drop this target to avoid repeating
# the same song more than once.
if target == key[-1]:
continue
if target != last_song:
tot += count
for target, count in target_map.iteritems():
if target != last_song:
cur += float(count) / tot
norm_vec.append((cur, target))
norm_map[key] = norm_vec
self._map = norm_map
def suggest(self, prev):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment