-
Notifications
You must be signed in to change notification settings - Fork 26
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
Optional sigmoid transformation and bugfix #44
Conversation
Signed-off-by: bkleyn <[email protected]>
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.
Thanks for getting to the issues, Bernard! The changes look good to me!
if contexts is None: | ||
num_contexts = 1 | ||
num_contexts = len(contexts) if contexts is not None else 1 | ||
if num_contexts == 1: |
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.
makes sense.. so this would make sure the output from predict_expectations is a list
if transform_scores: | ||
expectations = expit(pd.DataFrame(expectations)[self.mab.arms].values) | ||
else: | ||
expectations = pd.DataFrame(expectations)[self.mab.arms].values |
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.
makes sense to me
mab2rec/rec.py
Outdated
@@ -288,7 +288,7 @@ def predict_expectations(self, contexts: Union[None, List[List[Num]], np.ndarray | |||
return self.mab.predict_expectations(contexts) | |||
|
|||
def recommend(self, contexts: Union[None, List[List[Num]], np.ndarray, pd.Series, pd.DataFrame] = None, | |||
excluded_arms: List[List[Arm]] = None, return_scores: bool = False) \ | |||
excluded_arms: List[List[Arm]] = None, return_scores: bool = False, transform_scores: bool = True) \ |
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.
can you remind me again why this was useful to have this option?
re: naming, given that this is a boolean.. is_sigmoid? has_sigmoid? has_sigmoid_transform? is_sigmoid_applied?
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.
is this a "breaking" change now, OR we are okay since it has a default setup as True
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.
No, not breaking. Optional argument and default behavior is the unchanged.
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.
re: naming - how about "apply_sigmoid"?
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.
@wddcheng when you get a chance, can you change this to apply_sigmoid, merge the PR, and close the related Issues please?
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.
will do!
changed transform_scores to apply_sigmoid. all tests passed. Merging the PR now |
No description provided.