syne_tune.optimizer.schedulers.searchers.bayesopt.models.cost.sklearn_cost_model module

class syne_tune.optimizer.schedulers.searchers.bayesopt.models.cost.sklearn_cost_model.ScikitLearnCostModel(model_type=None)[source]

Bases: NonLinearCostModel

Deterministic cost model, where c0(x) = b0 (constant), and c1(x) is given by a scikit.learn (or scipy) regression model. Parameters are b0 and those of the regression model.

Parameters:

model_type (Optional[str]) – Regression model for c1(x)

transform_dataset(dataset, num_data0, res_min)[source]

Transforms dataset (see _data_for_c1_regression()) into a dataset representation (dict), which is used as kwargs in fit_regressor().

Parameters:
  • dataset (List[Tuple[Dict[str, Union[int, float, str]], float]]) –

  • num_data0 (int) –

  • res_min (int) –

Return type:

Dict[str, Any]

Returns:

Used as kwargs in fit_regressor

static fit_regressor(b0, **kwargs)[source]

Given value for b0, fits regressor to dataset specified via kwargs (see transform_dataset()). Returns the criterion function value for b0 as well as the fitted regression model.

Parameters:
  • b0 (float) –

  • kwargs

Returns:

fval, model

predict_c1_values(candidates)[source]
Parameters:

candidates (List[Dict[str, Union[int, float, str]]]) – Test configs

Returns:

Corresponding c1 values

class syne_tune.optimizer.schedulers.searchers.bayesopt.models.cost.sklearn_cost_model.UnivariateSplineCostModel(scalar_attribute, input_range, spline_degree=3)[source]

Bases: NonLinearCostModel

Here, c1(x) is given by a univariate spline (UnivariateSpline), where a single scalar is extracted from x.

In the second part of the dataset (pos >= num_data0), duplicate entries with the same config in dataset are grouped into one, using the mean as target value, and a weight equal to the number of duplicates. This still leaves duplicates in the overall dataset, one in data0, the other in data1, but spline smoothing can deal with this.

transform_dataset(dataset, num_data0, res_min)[source]

Transforms dataset (see _data_for_c1_regression()) into a dataset representation (dict), which is used as kwargs in fit_regressor().

Parameters:
  • dataset (List[Tuple[Dict[str, Union[int, float, str]], float]]) –

  • num_data0 (int) –

  • res_min (int) –

Return type:

Dict[str, Any]

Returns:

Used as kwargs in fit_regressor

static fit_regressor(b0, **kwargs)[source]

Given value for b0, fits regressor to dataset specified via kwargs (see transform_dataset()). Returns the criterion function value for b0 as well as the fitted regression model.

Parameters:
  • b0 (float) –

  • kwargs

Returns:

fval, model

predict_c1_values(candidates)[source]
Parameters:

candidates (List[Dict[str, Union[int, float, str]]]) – Test configs

Returns:

Corresponding c1 values