Skip to content

Commit

Permalink
Allowing full table sampling in acquisition
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeratyoy committed Nov 6, 2023
1 parent 41df811 commit 0651ff8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/neps/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def run(
# Used to create the yaml holding information about the searcher.
# Also important for testing and debugging the api.
searcher_info = {
"searcher_name": searcher,
"searcher_name": str(searcher),
"searcher_alg": searcher_alg,
"user_defined_searcher": user_defined_searcher,
"searcher_args_user_modified": False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ def __init__(self, **kwargs):
self.b_step = None
self.n = None
self.pipeline_space = None
# args to manage tabular spaces/grid
self.is_tabular = False
self.sample_full_table = None
self.set_sample_full_tabular(True) # sets flag that samples full table

def set_sample_full_tabular(self, flag: bool=False):
if self.is_tabular:
self.sample_full_table = flag

def _sample_new(
self, index_from: int, n: int = None, ignore_fidelity: bool = False
Expand Down Expand Up @@ -119,8 +126,11 @@ def __sample_single_new_tabular(index: int):
_n = n if n is not None else self.SAMPLES_TO_DRAW
_partial_ids = {conf["id"].value for conf in partial_configs}
_all_ids = set(self.pipeline_space.custom_grid_table.index.values)
# accounting for unseen configs only
_n = min(_n, len(_all_ids - _partial_ids))

# accounting for unseen configs only, samples remaining table if flag is set
max_n = len(_all_ids) + 1 if self.sample_full_table else _n
_n = min(max_n, len(_all_ids - _partial_ids))

_new_configs = np.random.choice(
list(_all_ids - _partial_ids), size=_n, replace=False
)
Expand Down

0 comments on commit 0651ff8

Please sign in to comment.