GridSearchCV
does allow param_grid
to be a list of grid-dicts, which sometimes is sufficient. In this case, separate grids are generated and their union is searched.
There isn't quite a convenient implementation by which you provide your own list of hyperparameter points. But looking at the source code for GridSearchCV
, you'll notice that it's amazingly sparse. Most everything is handled by the inherited class BaseSearchCV
. The grid-specific stuff is also factored out:
def _run_search(self, evaluate_candidates):
"""Search all candidates in param_grid"""
evaluate_candidates(ParameterGrid(self.param_grid))
The ParameterGrid
class is what's responsible for turning the (possibly list of) dict(s) into a grid(s).
So you could probably easily write a custom class, inheriting from BaseSearchCV
, where you pass the set of hyperparameter points you want and define _run_search
to just evaluate each element from your set. In fact, already evaluate_candidates
is defined assuming that the hyperparameter points live in an iterable candidate_params
; the ParameterGrid
does all the hard work there, but in your case you can just feed your list directly.