INNER CODE UNIT · Python
_sample_parameters
AnotherSamWilson/miceforest · miceforest/default_lightgbm_parameters.py:38
def _sample_parameters(parameters: dict, random_state, parameter_sampling_method: str):
"""
Searches through a parameter set and selects a random
number between the values in any provided tuple of length 2.
"""
assert (
parameter_sampling_method == "random"
), "Only random parameter sampling is supported right now."
parameters = parameters.copy()
for p, v in parameters.items():
if isinstance(v, list):
choice = random_state.choice(v)
elif isinstance(v, tuple):
assert (
len(v) == 2
), "Tuples passed must be length 2, representing the bounds."
assert v[0] < v[1], f"{p} lower bound > upper bound"
if p in _LOG_SPACE_SEARCH: