logml.model_search.hp_optimizer
Functions
|
Parses a given HPO config and returns a fmin with predefined params. |
|
Transforms a given params space config into a HyperOpt space Also supports embedded structures. |
Classes
|
Result of HyperParamsOptimizerCore class. |
|
Applies HyperOpt to find the best hyperparams for a given model. |
|
Model HPO result |
Utility for retrieving hyperopt-compatible trial results. |
Exceptions
Exception raised when there is an Exception caught while hyper-parameters optimization. |
- class logml.model_search.hp_optimizer.HpoResult(name: str, best_params: Optional[dict] = None, trials: Optional[hyperopt.base.Trials] = None, all_trials_failed: bool = False)
Bases:
object
Result of HyperParamsOptimizerCore class.
- name: str
- best_params: Optional[dict] = None
- trials: hyperopt.base.Trials = None
- all_trials_failed: bool = False
- class logml.model_search.hp_optimizer.HyperParamsOptimizerCore(hpo_algorithm='tpe', max_evals=10, logger=None, show_progressbar=True, random_state=None)
Bases:
object
Applies HyperOpt to find the best hyperparams for a given model. Class is stateless and can be reused to train different models without side effects.
By the principle of separation of core components and infrastructure: HyperParamsOptimizerCore can only calculate, while HyperParamsOptimizer wraps it, and can save-load data as needed.
- search(model_cls: Type[logml.models.base.BaseModel], hpo_space: dict, dataset: logml.data.datasets.cv_dataset.ModelingDataset, default_params: Optional[dict] = None, random_state=None, test_default_params=True) logml.model_search.hp_optimizer.HpoResult
Runs HyperOpt to find the best params for a given model.
- class logml.model_search.hp_optimizer.ModelHpoResult(name: str, best_params: Optional[dict] = None, trials: Optional[List[dict]] = None, all_trials_failed: bool = False)
Bases:
object
Model HPO result
- name: str
- best_params: Optional[dict] = None
- trials: Optional[List[dict]] = None
- all_trials_failed: bool = False
- logml.model_search.hp_optimizer.create_hopt_space(params_space_cfg: Optional[dict], default_params=None)
Transforms a given params space config into a HyperOpt space Also supports embedded structures.
Returns hyperopt search space.
- logml.model_search.hp_optimizer.create_fmin(hpo_cfg: logml.configuration.modeling.HPOSection)
Parses a given HPO config and returns a fmin with predefined params.
- exception logml.model_search.hp_optimizer.HyperParamsOptimizerException
Bases:
Exception
Exception raised when there is an Exception caught while hyper-parameters optimization.
- class logml.model_search.hp_optimizer.TrialResults
Bases:
object
Utility for retrieving hyperopt-compatible trial results.
- static get_cv_scores(model: logml.models.base.BaseModel, dataset: logml.data.datasets.cv_dataset.ModelingDataset)
Returns evaluation results. Also casts np.float into float, for serialization.
- static get_loss(model: logml.models.base.BaseModel, dataset: logml.data.datasets.cv_dataset.ModelingDataset) float
Calculates the result loss based on CV scores.
- static extract(model, dataset: logml.data.datasets.cv_dataset.ModelingDataset)
Extracts trial results from a given model and dataset.
- static create_failed_result(message)
Returns the default placeholder for failed trials.