def models_grid(self, **kwargs):
<EOL>self.check_valid_keys(kwargs)<EOL>for (key, value) in kwargs.items():<EOL><INDENT>if not isinstance(value, list):<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>% (key, str(type(value))))<EOL><DEDENT><DEDENT>parameters = dict(<EOL>(key, [value]) for (key, value) in self.defaults.items())<EOL>parameters.update(kwargs)<EOL>parameter_names = list(parameters)<EOL>parameter_values = [parameters[name] for name in parameter_names]<EOL>models = [<EOL>dict(zip(parameter_names, model_values))<EOL>for model_values in itertools.product(*parameter_values)<EOL>]<EOL>return models<EOL>
Make a grid of models by taking the cartesian product of all specified
model parameter lists.

Parameters
-----------
The valid kwarg parameters are the entries of this
HyperparameterDefaults instance. Each parameter must be a list
giving the values to search across.

Returns
-----------
list of dict giving the parameters for each model. The length of the
list is the product of the lengths of the input lists.