This repository was archived by the owner on Nov 8, 2024. It is now read-only.
[ff-2388] get_bandit_actions: supply actions as a dict instead of list#53
Merged
[ff-2388] get_bandit_actions: supply actions as a dict instead of list#53
Conversation
giorgiomartini0
approved these changes
Jun 10, 2024
| optimality_gap = ( | ||
| max(score for _, score in action_scores) - action_scores[selected_idx][1] | ||
| ) | ||
| optimality_gap = max(action_scores.values()) - action_scores[selected_action] |
aarsilv
approved these changes
Jun 10, 2024
| subject_key: str, | ||
| subject_attributes: Attributes, | ||
| actions_with_contexts: List[ActionContext], | ||
| actions: ActionContexts, |
Contributor
There was a problem hiding this comment.
should we still keep this namedactions_with_contexts?
Author
There was a problem hiding this comment.
Thought about it -- given that we expect a dictionary now, I think it's more obvious that we need extra information to go with the key
| @@ -1 +1 @@ | |||
| __version__ = "3.1.4" | |||
| __version__ = "3.2.0" | |||
Contributor
There was a problem hiding this comment.
technically this interface change is a non-backward compatible breaking change, but fine doing the 3.2 thing
| assert pytest.approx(evaluation.action_weight, rel=1e-2) == 0.4926 | ||
|
|
||
|
|
||
| def test_bandit_no_action_contexts(): |
| flag_key, | ||
| subject_key, | ||
| subject_attributes, | ||
| {"action1": Attributes.empty(), "action2": Attributes.empty()}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #ff-2388
Motivation and Context
Currently actions are supplied as a list, which does not guarantee that the action keys are unique. To ensure uniqueness, require a dictionary mapping actions to their contexts instead
Description
bandit.pyto use dicts for computation instead of listsHow has this been tested?
All tests pass