-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix landing page after a click #27
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,11 +102,21 @@ def reset(self, user_id=0): | |
# Record number of times each product seen for static policy calculation. | ||
self.organic_views = np.zeros(self.config.num_products) | ||
|
||
def generate_organic_sessions(self): | ||
def generate_organic_sessions(self, initial_product = None): | ||
|
||
# Initialize session. | ||
session = OrganicSessions() | ||
|
||
if initial_product is not None : | ||
# If a product is specified, use it as initial page for the organic session | ||
session.next( | ||
DefaultContext(self.current_time, self.current_user_id), | ||
initial_product | ||
) | ||
|
||
# Update markov state. | ||
self.update_state() | ||
|
||
while self.state == organic: | ||
# Add next product view. | ||
self.update_product_view() | ||
|
@@ -179,10 +189,13 @@ def step(self, action_id): | |
|
||
if reward == 1: | ||
self.state = organic # After a click, Organic Events always follow. | ||
|
||
initial_product = action_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we mix up Bandit (action_id) with Organic? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The goal is to land on the product that was clicked in the organic session that follows a successful bandit event. Currently, there is no relationship between the clicked product and the first organic item viewed afterwards. |
||
else : | ||
initial_product = None | ||
|
||
# Markov state dependent logic. | ||
if self.state == organic: | ||
sessions = self.generate_organic_sessions() | ||
sessions = self.generate_organic_sessions(initial_product) | ||
else: | ||
sessions = self.empty_sessions | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Time is not updated, thus BOTH events
Bandit (with Action ID = initial_product)
Organic (with the Product ID = initial_product)
will happen at the same time.
In the case when `initial_product is not None' and we update the state, the state could not be 'organic', that means that we could not generate pure/real Organic events (we do not enter to the following while loop).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Time is updated in update_state. For the first organic event after a bandit event, it will be updated in the update_state command of the step function, just after a click has been drawn. Thus we won't encounter the problem of having a bandit event and an organic event at the same time.
We are in the organic state even though the initial_product is not None (we just choose how to start the organic session), thus the state update works as usual, and we are able to generate organic events, with the only difference that we can choose the initial page of the organic session, which could be useful just after a click.