-
Notifications
You must be signed in to change notification settings - Fork 47
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
Move allow_*
flags to Campaign
#423
Conversation
2ccb684
to
f79b557
Compare
0987d10
to
99d0428
Compare
491c79d
to
88ab485
Compare
88ab485
to
818741b
Compare
Fixes #371 by making `SubspaceDiscrete` stateless. ### Current Approach * The `SubspaceDiscrete.metadata` attribute gets deprecated and the responsibility of metadata handling is shifted to `Campaign` * The new mechanism is not yet final (see out of scope below) but designed in a way that allows to implement upcoming changes in a non-breaking manner. In particular: * The metadata handling mechanism is redesigned in that the actual metadata representation is completely hidden from the user, i.e. campaign manages the data in form of private attributes. This is to avoid further lock-in into `pandas` as our search space backend and prepares for future search space improvements by abstracting away the specific implementation details, enabling us to easily offer other backends (polars, databases, etc) in the future. * The `allow_*` flags are not yet migrated to the `Campaign` class, but the `AnnotatedSubspaceDiscrete` allows to migrate them in a follow-up PR (#423) without causing much friction * A new user-facing method `Campaign.toggle_discrete_candidates` now allows convenient and dynamic control over the discrete candidate set, avoiding any fiddling with the backend dataframes and index manipulations. The positive effect can be seen in the much cleaner code parts of the simulation package. ### Out of scope / (potentially) coming next * Migration of `allow_*` flags in order to make `Campaign` the unique place where the concept of metadata exists, i.e. campaigns will be the only stateful objects. A PR taking care of this should follow soon because the `get_candidates` signature of `SubspaceDiscrete` currently makes not much sense, as it expects these flags in a context where metadata does not exist. * Once the flags are migrated, the `AnnotatedSubspaceDiscrete` might become obsolete since the `Campaign` class can then theoretically filter down the space before passing it to the recommender. This however requires an efficient implementation that does not cause unnecessary dataframe copies. * Actually turning the state space classes `frozen`. There a few other things that should be addressed at the same time (i.e. general cleanup of the classes).
818741b
to
1d23a9d
Compare
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.
Very brief set of initial comments. More to come.
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.
LGTM, just some minor questions/comments
048d5eb
to
e366077
Compare
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.
Since most if my wishes have been implemented, here you go with your approve :)
dfa7a70
to
82220e8
Compare
This PR refines the semantics of Meta recommenders and extends their use. It was motivated by two problems: * First one arising in #423 where `pending_experiments` should only be passed to `BayesianRecommenders`. Unfortunately, with the current meta recommender interface, it is not straightforward (or impossible?) to identify what exactly the next recommender will be – which indicates a suboptimal design. * Second: fixes #420 The important things changed: * `MetaRecommender`s now have a much simpler logic, i.e. they only contain a `select_recommender`, which *always* just returns the recommender appropriate for the context of the call. Previous statefulness, which was only relevant to sequential recommenders, has been moved to the corresponding classes. * They now have an `is_stateful` Boolean property * They now have an `get_non_meta_recommender` method for extracting the appropriate context-specific non-meta recommender from the hierarchy * They can now be composed of arbitrary other meta recommenders. The previous restriction that they need to be composed of pure recommenders was an unnecessary limitation. Allowing other meta recommenders as building blocks can indeed be indeed useful, for example, using a two-phase recommender where the second phase uses an adaptive (e.g. batch-size dependent) meta recommender. * ~~Added the new `BatchSizeAdaptiveMetaRecommender`, which can be useful, e.g. to avoid too costly optimizations for large batch sizes.~~ * `TwoPhaseMetaRecommender` now has an explicit `remain_switch` option to clarify its behavior.
e449175
to
4dc4f2f
Compare
f387c02
to
4992621
Compare
4992621
to
e19fa39
Compare
Reset the default of `allow_recommending_already_recommended` back to `False`, which was forgotten in #423.
This PR builds upon #412 and finalizes the metadata migration from search spaces / recommenders to
Campaign
, makingCampaign
the only stateful class:allow_*
flags are now passed directly toCampaign
, strengthening the role ofCampaign
as the class for metadata handling / tracking the progress of an experimentation path.allow_repeated_recommendations
is renamed toallow_recommending_already_recommended
because i) the original name was imprecise in that it also suggested that repetitions are disallowed within a batch and ii) the new follows the same pattern as the other two flags.AnnotatedSubspaceDiscrete
with a new private classFilteredSubspaceDiscrete
taking over the original role but without the necessity of being metadata aware.Coming next
The changes introduced here and in #423 bring significant improvements from a user interface perspective in that:
Constraint
objects and candidates dataframes.pandas
part of the current discrete search space implementation is less entangled in the code baseThis paves the way for upcoming enhancements:
SubspaceDiscreteProtocol
is already in sight, which allows seamless integration of other backends (polars
, databases, etc) and will help us complete the ongoingpolars
transition.SubspaceDiscrete.filter(constraints)
, which can also become the backbone of the current constraints logic