Skip to content
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

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

bkleyn
Copy link
Contributor

@bkleyn bkleyn commented Feb 22, 2024

No description provided.

Signed-off-by: bkleyn <[email protected]>
@bkleyn bkleyn requested a review from skadio as a code owner February 22, 2024 19:27
@bkleyn bkleyn linked an issue Feb 22, 2024 that may be closed by this pull request
@bkleyn bkleyn requested a review from wddcheng February 22, 2024 19:27
@bkleyn bkleyn linked an issue Feb 22, 2024 that may be closed by this pull request
Copy link
Contributor

@wddcheng wddcheng left a 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:
Copy link
Contributor

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
Copy link
Contributor

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) \
Copy link
Collaborator

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?

Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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"?

Copy link
Collaborator

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do!

@wddcheng
Copy link
Contributor

wddcheng commented Mar 7, 2024

changed transform_scores to apply_sigmoid. all tests passed. Merging the PR now

@wddcheng wddcheng merged commit cd38ecd into main Mar 7, 2024
11 checks passed
@wddcheng wddcheng deleted the feature/optional_transform branch March 7, 2024 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants