onetick.ml.utils#

build_experiment(config: Union[dict, str] = {}, globals_dict: dict = {})[source]#

Build onetick.ml.Experiment instance from dict-config

Parameters
  • config (dict) – Configuration dict with settings tree

  • globals_dict (dict, optional) – Supply globals() dict, to restore custom classes. Defaults to {}.

Returns

onetick.ml.Experiment class instance builded from config dict

Return type

any

build_experiment_class(config: Union[dict, str] = {}, globals_dict: dict = {})[source]#

Build onetick.ml.Experiment class from dict-config

Parameters
  • config (dict) – Configuration dict with settings tree

  • globals_dict (dict, optional) – Supply globals() dict, to restore custom classes. Defaults to {}.

Returns

onetick.ml.Experiment class builded from config dict

Return type

any

restore_experiment_from_mlflow(run_id: str, mlflow_url: Optional[str] = None)[source]#

Builds Experiment class from YAML config loaded from MLFlow.

Parameters
  • run_id (str) – MLFlow Run ID to restore from

  • mlflow_url (Optional[str], optional) – MLFlow Tracking URI. Defaults to None.

Returns

onetick.ml.Experiment

Return type

instance inherited from onetick.ml.Experiment class restored from MLFlow run

params_iterator(model_params)[source]#

Iterate over grid returning combinations.

Parameters

model_params (dict) – Grid of parameters to iterate over

Yields

dict – One combination of parameters from grid.

create_folds(x_train=None, x_val=None, y_val=None, val_type: Literal['None', 'Simple', 'Cross', 'WalkForward'] = 'None', folds_num=5)[source]#

Create folds for cross-validation

Parameters
  • x_train (pandas.DataFrame, optional) – Features for training, by default None

  • x_val (pandas.DataFrame, optional) – Features for validation, by default None

  • y_val (pandas.DataFrame, optional) – Targets for validation, by default None

  • val_type (Literal["None", "Simple", "Cross", "WalkForward"], optional) – Cross-validation type, by default “None”

  • folds_num (int, optional) – Number of folds, by default 5

Returns

Folds indices generator used for cross-validation (GridSearchCV or RandomizedSearchCV) in onetick.ml.Experiment

Return type

any

class ExperimentBuilder(config: Union[dict, str] = {}, globals_dict: dict = {})[source]#

Builder class used to restore Experiment from YAML/dict config.

Parameters
  • config (Union[dict, str]) – YAML config or dict with config.

  • globals_dict (dict) – Dict with globals, used to restore classes from global scope.

static get_class_name(class_obj)[source]#

Returns class name with module name.

Parameters

class_obj (class) – Class object.

Returns

Class name with module name.

Return type

str

get_class_def(class_qualname)[source]#

Returns class object (not instance) by class name with module name.

Parameters

class_qualname (str) – Class name with module name.

Returns

Class object (not instance).

Return type

class

build_experiment_class()[source]#

Builds on-fly Experiment class with config loaded from YAML.

Returns

Experiment class built from YAML config supplied to builder.

Return type

class