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 of a, 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 to finrange(), logfinrange(), ordinal(), or logordinal(). Otherwise, domain is returned as is.

The idea is to compute the least squares fit \(a * j + b\) to x[j], where x 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 types finrange or logfinrange, otherwise we use ordinal or logordinal.

Return type:

Domain

syne_tune.utils.convert_domain.convert_linear_to_log_domain(domain, name=None)[source]
Return type:

Domain

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 to finrange(), logfinrange(), ordinal(), or logordinal(). 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, where ordinal is with kind="nn". Note that the conversion to (log)finrange may result in slightly different values.

  • domain is float` or ``int. This is converted to the same type, but in log scale, if the current scale is linear, lower is positive, and the ratio upper / lower is larger than UPPER_LOWER_RATIO_THRESHOLD.

Parameters:

domain (Domain) – Original domain

Return type:

Domain

Returns:

Streamlined domain

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 in exclude_names are not replaced.

See convert_domain() for what replacement rules may be applied.

Parameters:
  • config_space (Dict[str, Any]) – Original configuration space

  • exclude_names (Optional[List[str]]) – Do not convert entries with these keys

  • verbose (bool) – Log output for replaced domains? Defaults to False

Return type:

Dict[str, Any]

Returns:

Streamlined configuration space