Skip to content

Commit

Permalink
satiation and registry bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ameliakovacs committed Jul 1, 2022
1 parent bc51654 commit 44e6bc0
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 2,227 deletions.
Binary file added .DS_Store
Binary file not shown.
14 changes: 7 additions & 7 deletions reclab/environments/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@
),
'beta-rank-v1': (
BetaRank,
dict(num_users=1000,
num_items=1700,
num_topics=19,
rating_frequency=0.2,
num_init_ratings=100000,
known_weight=0.98,
beta_var=1e-05)
dict(
dimension=19,
num_users=1000,
num_items=1700,
rating_frequency=0.2,
num_init_ratings=100000,
known_mean=0.98)
),
}

Expand Down
9 changes: 6 additions & 3 deletions reclab/environments/topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def name(self): # noqa: D102

def _get_dense_ratings(self): # noqa: D102
ratings = np.zeros([self._num_users, self._num_items])
print(self._satiations)
for item_id in range(self._num_items):
topic = self._item_topics[item_id]
ratings[:, item_id] = (self._user_preferences[:, topic] +
Expand Down Expand Up @@ -174,12 +175,13 @@ def _rate_items(self, user_id, item_ids): # noqa: D102
item_id = [item_ids[0]]
rating = self._get_rating(user_id, item_id)
topic = self._item_topics[item_id]
curr_sat = self._satiations[user_id][0]

# Update satiation.
recommended = np.zeros(self._num_topics)
recommended[topic] = 1
self._satiations = (self._satiation_decay * (self._satiations + recommended) +
np.random.randn(self._num_topics) * self._satiation_noise)
self._satiations[user_id] = (self._satiation_decay * (self._satiations[user_id] + recommended) +
np.random.randn(self._num_topics) * self._satiation_noise)
# print(self._satiations)

# Update underlying preference.
Expand All @@ -189,8 +191,9 @@ def _rate_items(self, user_id, item_ids): # noqa: D102
not_topic = np.arange(self._num_topics) != topic
self._user_preferences[user_id, not_topic] -= (
self._topic_change / (self._num_topics - 1))

print(str(user_id) + "\t" + str(item_id[0]) +
"\t" + str(topic[0]) + "\t" + str(rating[0]) + "\t" + str(self._satiations[user_id][0]))
"\t" + str(topic[0]) + "\t" + str(rating[0]) + "\t" + str(curr_sat))
return rating

def _reset_state(self): # noqa: D102
Expand Down
200 changes: 0 additions & 200 deletions sats.txt

This file was deleted.

Binary file removed sats.xls
Binary file not shown.
Loading

0 comments on commit 44e6bc0

Please sign in to comment.