GridSearch
- class sherpa.optmethods.GridSearch(name='gridsearch')[source] [edit on github]
Bases:
OptMethodGrid Search optimization method.
This method evaluates the fit statistic for each point in the parameter space grid; the best match is the grid point with the lowest value of the fit statistic. It is intended for use with template models as it is very inefficient for general models.
- num
The size of the grid for each parameter when
sequenceisNone, sonpar^numfits will be evaluated, wherenparis the number of free parameters. The grid spacing is uniform.- Type:
- sequence
The list through which to evaluate. Leave as
Noneto use a uniform grid spacing as determined by thenumattribute.- Type:
sequence of numbers or
None
- numcores
The number of CPU cores to use. The default is
1and a value ofNonewill use all the cores on the machine.- Type:
int or
None
- method
The optimization method to use to refine the best-fit location found using the grid search. If
Nonethen this step is not run.- Type:
str or
None
- verbose
The amount of information to print during the fit. The default is
0, which means no output.- Type:
Attributes Summary
The default settings for the optimiser.
Methods Summary
fit(statfunc, pars, parmins, parmaxes[, ...])Run the optimiser.
Attributes Documentation
- default_config
The default settings for the optimiser.
Methods Documentation
- fit(statfunc, pars, parmins, parmaxes, statargs=(), statkwargs=None) [edit on github]
Run the optimiser.
Changed in version 4.16.0: The statkwargs argument now defaults to None rather than {}.
- Parameters:
statfunc (function) – Given a list of parameter values as the first argument and, as the remaining positional arguments,
statargsandstatkwargsas keyword arguments, return the statistic value.pars (sequence) – The start position of the model parameter values.
parmins (sequence) – The minimum allowed values for each model parameter. This must match the length of
pars.parmaxes (sequence) – The maximum allowed values for each model parameter. This must match the length of
pars.statargs (optional) – Additional positional arguments to send to
statfunc.statkwargs (dict, optional) – Additional keyword arguments to send to
statfunc.
- Returns:
newpars – The tuple contains: boolean indicating whether the optimization succeeded or not, the best fit parameters as a NumPy array, the statistic value at the best-fit location, a string message indicating the status, and a dictionary containing information about the optimisation (this depends on the optimiser).
- Return type: