fitAlgs.minimize module¶
Author: | Dominic Hunt |
---|
-
class
fitAlgs.minimize.
Minimize
(method=None, number_start_points=4, allow_boundary_fits=True, boundary_fit_sensitivity=5, **kwargs)[source]¶ Bases:
fitAlgs.fitAlg.FitAlg
The class for fitting data using scipy.optimise.minimize
Parameters: - fit_sim (fitAlgs.fitSims.FitSim instance, optional) – An instance of one of the fitting simulation methods. Default
fitAlgs.fitSims.FitSim
- fit_measure (string, optional) – The name of the function used to calculate the quality of the fit.
The value it returns provides the fitter with its fitting guide. Default
-loge
- fit_measure_args (dict, optional) – The parameters used to initialise fit_measure and extra_fit_measures. Default
None
- extra_fit_measures (list of strings, optional) – List of fit measures not used to fit the model, but to provide more information. Any arguments needed for these
measures should be placed in fit_measure_args. Default
None
- bounds (dictionary of tuples of length two with floats, optional) – The boundaries for methods that use bounds. If unbounded methods are
specified then the bounds will be ignored. Default is
None
, which translates to boundaries of (0, np.inf) for each parameter. - boundary_excess_cost (basestring or callable returning a function, optional) – The function is used to calculate the penalty for exceeding the boundaries.
Default is
boundFunc.scalarBound()
- boundary_excess_cost_properties (dict, optional) – The parameters for the boundary_excess_cost function. Default {}
- method (string or list of strings, optional) – The name of the fitting method or list of names of fitting methods or
name of list of fitting methods. Valid names found in the notes.
Default
unconstrained
- number_start_points (int, optional) – The number of starting points generated for each parameter. Default 4
- allow_boundary_fits (bool, optional) – Defines if fits that reach a boundary should be considered the same way as those that do not. Default is True
- boundary_fit_sensitivity (int, optional) – Defines the smallest number of decimal places difference (so the
minimal difference) between a parameter value and its related boundaries
before a parameter value is considered different from a boundary. The default
is 5. This is only valid if
allow_boundary_fits
isFalse
-
Name
¶ The name of the fitting method
Type: string
Notes
unconstrained = [‘Nelder-Mead’,’Powell’,’CG’,’BFGS’] constrained = [‘L-BFGS-B’,’TNC’,’SLSQP’] Custom fitting algorithms are also allowed in theory, but it has yet to be implemented.
For each fitting function a set of different starting parameters will be tried. These are the combinations of all the values of the different parameters. For each starting parameter provided a set of number_start_points starting points will be chosen, surrounding the starting point provided. If the starting point provided is less than one it will be assumed that the values cannot exceed 1, otherwise, unless otherwise told, it will be assumed that they can take any value and will be chosen to be eavenly spaced around the provided value.
See also
fitAlgs.fitAlg.fitAlg
- The general fitting method class, from which this one inherits
fitAlgs.fitSims.fitSim
- The general fitSim class
scipy.optimise.minimize
- The fitting class this wraps around
-
constrained
= [u'L-BFGS-B', u'TNC', u'SLSQP']
-
fit
(simulator, model_parameter_names, model_initial_parameters)[source]¶ Runs the model through the fitting algorithms and starting parameters and returns the best one.
Parameters: - simulator (function) – The function used by a fitting algorithm to generate a fit for given model parameters. One example is fitAlgs.fitAlg.fitness
- model_parameter_names (list of strings) – The list of initial parameter names
- model_initial_parameters (list of floats) – The list of the initial parameters
Returns: - best_fit_parameters (list of floats) – The best fitting parameters
- fit_quality (float) – The quality of the fit as defined by the quality function chosen.
- testedParams (tuple of two lists) – The two lists are a list containing the parameter values tested, in the order they were tested, and the fit qualities of these parameters.
See also
fitAlgs.fitAlg.fitness()
-
unconstrained
= [u'Nelder-Mead', u'Powell', u'CG', u'BFGS']
- fit_sim (fitAlgs.fitSims.FitSim instance, optional) – An instance of one of the fitting simulation methods. Default