Bases: optunity.solvers.util.Solver
Please refer to Grid Search for more information about this algorithm.
Exhaustive search over the Cartesian product of parameter tuples. Returns x (the tuple which maximizes f) and its score f(x).
>>> s = GridSearch(x=[1,2,3], y=[-1,0,1])
>>> best_pars, _ = s.optimize(lambda x, y: x*y)
>>> best_pars['x']
3
>>> best_pars['y']
1
Initializes the solver with a tuple indicating parameter values.
>>> s = GridSearch(x=[1,2], y=[3,4])
>>> s.parameter_tuples['x']
[1, 2]
>>> s.parameter_tuples['y']
[3, 4]
Assigns equally spaced grid points with given density in [ub, lb]. The bounds are always used. density must be at least 2.
Parameters: |
|
---|
>>> s = GridSearch.assign_grid_points(1.0, 2.0, 3)
>>> s
[1.0, 1.5, 2.0]
Maximizes f.
Parameters: |
|
---|---|
Returns: |
|
Minimizes f.
Parameters: |
|
---|---|
Returns: |
|
Optimizes f.
Parameters: |
|
---|---|
Returns: |
|
Creates a GridSearch solver that uses less than num_evals evaluations within given bounds (lb, ub). The bounds are first tightened, resulting in new bounds covering 99% of the area.
The resulting solver will use an equally spaced grid with the same number of points in every dimension. The amount of points that is used is per dimension is the nth root of num_evals, rounded down, where n is the number of hyperparameters.
>>> s = GridSearch.suggest_from_box(30, x=[0, 1], y=[-1, 0], z=[-1, 1])
>>> s['x']
[0.005, 0.5, 0.995]
>>> s['y']
[-0.995, -0.5, -0.005]
>>> s['z']
[-0.99, 0.0, 0.99]