class sklearn.grid_search.ParameterGrid(param_grid)[source]

Grid of parameters with a discrete number of values for each.

Deprecated since version 0.18: This module will be removed in 0.20. Use sklearn.model_selection.ParameterGrid instead.

Can be used to iterate over parameter value combinations with the Python built-in function iter.

Read more in the User Guide.


param_grid : dict of string to sequence, or sequence of such

The parameter grid to explore, as a dictionary mapping estimator parameters to sequences of allowed values.

An empty dict signifies default parameters.

A sequence of dicts signifies a sequence of grids to search, and is useful to avoid exploring parameter combinations that make no sense or have no effect. See the examples below.

See also

uses ParameterGrid to perform a full parallelized parameter search.


>>> from sklearn.grid_search import ParameterGrid
>>> param_grid = {'a': [1, 2], 'b': [True, False]}
>>> list(ParameterGrid(param_grid)) == (
...    [{'a': 1, 'b': True}, {'a': 1, 'b': False},
...     {'a': 2, 'b': True}, {'a': 2, 'b': False}])
>>> grid = [{'kernel': ['linear']}, {'kernel': ['rbf'], 'gamma': [1, 10]}]
>>> list(ParameterGrid(grid)) == [{'kernel': 'linear'},
...                               {'kernel': 'rbf', 'gamma': 1},
...                               {'kernel': 'rbf', 'gamma': 10}]
>>> ParameterGrid(grid)[1] == {'kernel': 'rbf', 'gamma': 1}
.. automethod:: __init__