neuraxle.metaopt.optimizer

Module-level documentation for neuraxle.metaopt.optimizer. Here is an inheritance diagram, including dependencies to other base modules of Neuraxle:


Neuraxle’s Hyperparameter Optimizer Base Classes

Not all hyperparameter optimizers are there, but the base can be found here.

Classes

BaseHyperparameterOptimizer

GridExplorationSampler(expected_n_trials, seed_i)

This hyperparameter space optimizer is similar to a grid search, however, it does try to greedily sample maximally different points in the space to explore it.

HyperparameterSamplerStub(…)

RandomSearchSampler()

AutoML Hyperparameter Optimizer that randomly samples the space of random variables.


class neuraxle.metaopt.optimizer.BaseHyperparameterOptimizer[source]

Bases: abc.ABC

find_next_best_hyperparams(round: neuraxle.metaopt.data.reporting.RoundReport, hp_space: neuraxle.hyperparams.space.HyperparameterSpace) → neuraxle.hyperparams.space.HyperparameterSamples[source]

Find the next best hyperparams using previous trials, that is the whole neuraxle.metaopt.data.aggregate.Round.

Return type

HyperparameterSamples

Parameters

round (RoundReport) – a neuraxle.metaopt.data.aggregate.Round

Returns

next hyperparameter samples to train on

_abc_impl = <_abc_data object>
class neuraxle.metaopt.optimizer.HyperparameterSamplerStub(preconfigured_hp_samples: neuraxle.hyperparams.space.HyperparameterSamples)[source]

Bases: neuraxle.metaopt.optimizer.BaseHyperparameterOptimizer

__init__(preconfigured_hp_samples: neuraxle.hyperparams.space.HyperparameterSamples)[source]

Initialize self. See help(type(self)) for accurate signature.

find_next_best_hyperparams(round: neuraxle.metaopt.data.reporting.RoundReport, hp_space: neuraxle.hyperparams.space.HyperparameterSpace) → neuraxle.hyperparams.space.HyperparameterSamples[source]

Find the next best hyperparams using previous trials, that is the whole neuraxle.metaopt.data.aggregate.Round.

Return type

HyperparameterSamples

Parameters

round (RoundReport) – a neuraxle.metaopt.data.aggregate.Round

Returns

next hyperparameter samples to train on

_abc_impl = <_abc_data object>
class neuraxle.metaopt.optimizer.RandomSearchSampler[source]

Bases: neuraxle.metaopt.optimizer.BaseHyperparameterOptimizer

AutoML Hyperparameter Optimizer that randomly samples the space of random variables. Please refer to AutoML for a usage example.

See also

Trainer, HyperparamsRepository,

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

find_next_best_hyperparams(round: neuraxle.metaopt.data.reporting.RoundReport, hp_space: neuraxle.hyperparams.space.HyperparameterSpace) → neuraxle.hyperparams.space.HyperparameterSamples[source]

Randomly sample the next hyperparams to try.

Return type

HyperparameterSamples

Parameters

round (RoundReport) – round report

Returns

next random hyperparams

_abc_impl = <_abc_data object>
class neuraxle.metaopt.optimizer.GridExplorationSampler(expected_n_trials: int = 0, seed_i: int = 0)[source]

Bases: neuraxle.metaopt.optimizer.BaseHyperparameterOptimizer

This hyperparameter space optimizer is similar to a grid search, however, it does try to greedily sample maximally different points in the space to explore it. This space optimizer has a fixed pseudorandom exploration method that makes the sampling reproductible.

When over the expected_n_trials (if sampling too much), the sampler will turn to a non-seeded random search.

It may be good for space exploration before a TPE or for unit tests.

If the expected_n_trials is not set or set to 0, the sampler will guess its ideal sampling count and then switch to random search after that.

__init__(expected_n_trials: int = 0, seed_i: int = 0)[source]

Initialize self. See help(type(self)) for accurate signature.

static estimate_ideal_n_trials(hp_space: neuraxle.hyperparams.space.HyperparameterSpace) → int[source]
_reinitialize_grid(hp_space: neuraxle.hyperparams.space.HyperparameterSpace, previous_trials_hp: List[neuraxle.hyperparams.space.HyperparameterSamples]) → neuraxle.hyperparams.space.HyperparameterSamples[source]

Update the grid exploration sampler.

Return type

HyperparameterSamples

Parameters

round_scope – round scope

Returns

next random hyperparams

find_next_best_hyperparams(round: neuraxle.metaopt.data.reporting.RoundReport, hp_space: neuraxle.hyperparams.space.HyperparameterSpace) → neuraxle.hyperparams.space.HyperparameterSamples[source]

Sample the next hyperparams to try.

Return type

HyperparameterSamples

Parameters

round_scope – round scope

Returns

next hyperparams

_generate_grid(hp_space: neuraxle.hyperparams.space.HyperparameterSpace)[source]

Generate the grid of hyperparameters to pick from.

Parameters

hp_space (HyperparameterSpace) – hyperparameter space

static _pseudo_shuffle_list(x: List[T], seed: int = 0) → list[source]

Shuffle a list to create a pseudo-random order that is interesting.

_gen_keys_for_grid() → List[int][source]

Generate the keys for the grid.

Parameters

i – index

Returns

keys

_reshuffle_grid(new_sample: OrderedDict[str, Any] = None)[source]

Reshuffling with pseudo-random seed the hyperparameters’ values:

_abc_impl = <_abc_data object>