syne_tune.utils.convert_domain module
- syne_tune.utils.convert_domain.fit_to_regular_grid(x)[source]
Computes the least squares fit of \(a * j + b\) to
x[j]
, where \(j = 0,\dots, n-1\). Returns the LS estimate ofa
,b
, and the coefficient of variation \(R^2\).- Parameters:
x (
ndarray
) – Strictly increasing sequence- Return type:
Dict
[str
,float
]- Returns:
See above
- syne_tune.utils.convert_domain.convert_choice_domain(domain, name=None)[source]
If the choice domain
domain
has more than 2 numerical values, it is converted tofinrange()
,logfinrange()
,ordinal()
, orlogordinal()
. Otherwise,domain
is returned as is.The idea is to compute the least squares fit \(a * j + b\) to
x[j]
, wherex
are the sorted values or their logs (if all values are positive). If this fit is very close (judged by coefficient of variation \(R^2\)), we use the equispaced typesfinrange
orlogfinrange
, otherwise we useordinal
orlogordinal
.- Return type:
- syne_tune.utils.convert_domain.convert_linear_to_log_domain(domain, name=None)[source]
- Return type:
- syne_tune.utils.convert_domain.convert_domain(domain, name=None)[source]
If one of the following rules apply,
domain
is converted and returned, otherwise it is returned as is.domain
is categorical, its values are numerical. This is converted tofinrange()
,logfinrange()
,ordinal()
, orlogordinal()
. We fit the values or their logs to the closest regular grid, converting to(log)finrange
if the least squares fit to the grid is good enough, otherwise to(log)ordinal
, whereordinal
is withkind="nn"
. Note that the conversion to(log)finrange
may result in slightly different values.domain
isfloat` or ``int
. This is converted to the same type, but in log scale, if the current scale is linear,lower
is positive, and the ratioupper / lower
is larger thanUPPER_LOWER_RATIO_THRESHOLD
.
- syne_tune.utils.convert_domain.streamline_config_space(config_space, exclude_names=None, verbose=False)[source]
Given a configuration space
config_space
, this function returns a new configuration space where some domains may have been replaced by approximately equivalent ones, which are however better suited for Bayesian optimization. Entries with key inexclude_names
are not replaced.See
convert_domain()
for what replacement rules may be applied.- Parameters:
config_space (
Dict
[str
,Any
]) – Original configuration spaceexclude_names (
Optional
[List
[str
]]) – Do not convert entries with these keysverbose (
bool
) – Log output for replaced domains? Defaults toFalse
- Return type:
Dict
[str
,Any
]- Returns:
Streamlined configuration space