grid_search_tuner#

Grid Search Optimizer, which generates all of the possible points to search for using a grid.

Module Contents#

Classes Summary#

GridSearchTuner

Grid Search Optimizer, which generates all of the possible points to search for using a grid.

Contents#

class evalml.tuners.grid_search_tuner.GridSearchTuner(pipeline_hyperparameter_ranges, n_points=10, random_seed=0)[source]#

Grid Search Optimizer, which generates all of the possible points to search for using a grid.

Parameters
  • pipeline_hyperparameter_ranges (dict) – a set of hyperparameter ranges corresponding to a pipeline’s parameters

  • n_points (int) – The number of points to sample from along each dimension defined in the space argument. Defaults to 10.

  • random_seed (int) – Seed for random number generator. Unused in this class, defaults to 0.

Examples

>>> tuner = GridSearchTuner({'My Component': {'param a': [0.0, 10.0], 'param b': ['a', 'b', 'c']}}, n_points=5)
>>> proposal = tuner.propose()
...
>>> assert proposal.keys() == {'My Component'}
>>> assert proposal['My Component'] == {'param a': 0.0, 'param b': 'a'}

Determines points using a grid search approach.

>>> for each in range(5):
...     print(tuner.propose())
{'My Component': {'param a': 0.0, 'param b': 'b'}}
{'My Component': {'param a': 0.0, 'param b': 'c'}}
{'My Component': {'param a': 10.0, 'param b': 'a'}}
{'My Component': {'param a': 10.0, 'param b': 'b'}}
{'My Component': {'param a': 10.0, 'param b': 'c'}}

Methods

add

Not applicable to grid search tuner as generated parameters are not dependent on scores of previous parameters.

get_starting_parameters

Gets the starting parameters given the pipeline hyperparameter range.

is_search_space_exhausted

Checks if it is possible to generate a set of valid parameters. Stores generated parameters in self.curr_params to be returned by propose().

propose

Returns parameters from _grid_points iterations.

add(self, pipeline_parameters, score)[source]#

Not applicable to grid search tuner as generated parameters are not dependent on scores of previous parameters.

Parameters
  • pipeline_parameters (dict) – a dict of the parameters used to evaluate a pipeline

  • score (float) – the score obtained by evaluating the pipeline with the provided parameters

get_starting_parameters(self, hyperparameter_ranges, random_seed=0)#

Gets the starting parameters given the pipeline hyperparameter range.

Parameters
  • hyperparameter_ranges (dict) – The custom hyperparameter ranges passed in during search. Used to determine the starting parameters.

  • random_seed (int) – The random seed to use. Defaults to 0.

Returns

The starting parameters, randomly chosen, to initialize a pipeline with.

Return type

dict

is_search_space_exhausted(self)[source]#

Checks if it is possible to generate a set of valid parameters. Stores generated parameters in self.curr_params to be returned by propose().

Returns

If no more valid parameters exists in the search space, return False.

Return type

bool

Raises

NoParamsException – If a search space is exhausted, then this exception is thrown.

propose(self)[source]#

Returns parameters from _grid_points iterations.

If all possible combinations of parameters have been scored, then NoParamsException is raised.

Returns

proposed pipeline parameters

Return type

dict