flexcode.helpers

Module Contents

Functions

box_transform(z, z_min, z_max)

Projects z from box [z_min, z_max] to [0, 1]

make_grid(n_grid, z_min, z_max)

Create grid of equally spaced points

params_dict_optim_decision(params[, multi_output])

Ingest parameter dictionary and determines whether to do CV optimization.

params_name_format(params, str_rem)

Changes all the key in dictionaries to remove a specific word from each key (estimator__).

box_transform(z, z_min, z_max)[source]

Projects z from box [z_min, z_max] to [0, 1]

Parameters:
  • z – an array of z values

  • z_min – float, the minimum value of the z box

  • z_max – float, the maximum value of the z box

Returns:

z projected onto [0, 1]

make_grid(n_grid, z_min, z_max)[source]

Create grid of equally spaced points

Parameters:
  • n_grid – integer number of grid points

  • z_min – float, the minimum value of the z box

  • z_max – float, the maximum value of the z box

Returns:

a grid of n_grid equally spaced points between z_min and z_max

params_dict_optim_decision(params, multi_output=False)[source]

Ingest parameter dictionary and determines whether to do CV optimization. If one of the parameter has a list of length above 1 as values then automatically format the dictionary for GridSearchCV.

Parameters:
  • params – dictionary of model parameters

  • multi_output – boolean flag, whether the optimization would need to be performed in MultiOutputRegressor

Returns:

a dictionary of parameters and a boolean flag of whether CV-opt is going to be performed. If CV-optimization is set to happen then the paramater dictionary is correctly format.

params_name_format(params, str_rem)[source]

Changes all the key in dictionaries to remove a specific word from each key (estimator__). This is because in order to GridsearchCV on MultiOutputRegressor one needs to use estimator__ in all parameters - but once the best parameters are fetched the name needs to be changed.

Parameters:
  • params – dictionary of model parameters

  • str_rem – word to be removed

Returns:

dictionary of parameters in which the word has been removed in keys