OptimizerMixin#
- class pyhf.optimize.mixins.OptimizerMixin(**kwargs)[source]#
Bases:
objectMixin Class to build optimizers.
Attributes
- maxiter#
- verbose#
Methods
- _internal_minimize(func, x0, do_grad=False, bounds=None, fixed_vals=None, options={}, par_names=None)[source]#
- _internal_postprocess(fitresult, stitch_pars, return_uncertainties=False)[source]#
Post-process the fit result.
- Returns:
A modified version of the fit result.
- Return type:
fitresult (scipy.optimize.OptimizeResult)
- minimize(objective, data, pdf, init_pars, par_bounds, fixed_vals=None, return_fitted_val=False, return_result_obj=False, return_uncertainties=False, return_correlations=False, do_grad=None, do_stitch=False, **kwargs)[source]#
Find parameters that minimize the objective.
- Parameters:
objective (
func) – objective functiondata (
list) – observed datapdf (Model) – The statistical model adhering to the schema model.json
init_pars (
listoffloat) – The starting values of the model parameters for minimization.par_bounds (
listoflist/tuple) – The extrema of values the model parameters are allowed to reach in the fit. The shape should be(n, 2)fornmodel parameters.fixed_vals (
listoflist/tuple) – The pairs of index and constant value for a constant model parameter during minimization. Set toNoneto allow all parameters to float.return_fitted_val (
bool) – Return bestfit value of the objective. Default is off (False).return_result_obj (
bool) – Returnscipy.optimize.OptimizeResult. Default is off (False).return_uncertainties (
bool) – Return uncertainties on the fitted parameters. Default is off (False).return_correlations (
bool) – Return correlations of the fitted parameters. Default is off (False).do_grad (
bool) – enable autodifferentiation mode. Default depends on backend (pyhf.tensorlib.default_do_grad).do_stitch (
bool) – enable splicing/stitching fixed parameter.kwargs – other options to pass through to underlying minimizer
- Returns:
parameters (
tensor): fitted parametersminimum (
float): ifreturn_fitted_valflagged, return minimized objective valueresult (
scipy.optimize.OptimizeResult): ifreturn_result_objflagged
- Return type:
Fitted parameters or tuple of results