Profile¶

class
pypesto.profile.
ProfileOptions
(default_step_size: float = 0.01, min_step_size: float = 0.001, max_step_size: float = 1.0, step_size_factor: float = 1.25, delta_ratio_max: float = 0.1, ratio_min: float = 0.145, reg_points: int = 10, reg_order: int = 4, magic_factor_obj_value: float = 0.5)¶ Bases:
dict
Options for optimization based profiling.
 Parameters
default_step_size – Default step size of the profiling routine along the profile path (adaptive step lengths algorithms will only use this as a first guess and then refine the update).
min_step_size – Lower bound for the step size in adaptive methods.
max_step_size – Upper bound for the step size in adaptive methods.
step_size_factor – Adaptive methods recompute the likelihood at the predicted point and try to find a good step length by a sort of line search algorithm. This factor controls step handling in this line search.
delta_ratio_max – Maximum allowed drop of the posterior ratio between two profile steps.
ratio_min – Lower bound for likelihood ratio of the profile, based on inverse chi2distribution. The default 0.145 is slightly lower than the 95% quantile 0.1465 of a chi2 distribution with one degree of freedom.
reg_points – Number of profile points used for regression in regression based adaptive profile points proposal.
reg_order – Maximum degree of regression polynomial used in regression based adaptive profile points proposal.
magic_factor_obj_value – There is this magic factor in the old profiling code which slows down profiling at small ratios (must be >= 0 and < 1).

__init__
(default_step_size: float = 0.01, min_step_size: float = 0.001, max_step_size: float = 1.0, step_size_factor: float = 1.25, delta_ratio_max: float = 0.1, ratio_min: float = 0.145, reg_points: int = 10, reg_order: int = 4, magic_factor_obj_value: float = 0.5)¶ Initialize self. See help(type(self)) for accurate signature.

static
create_instance
(maybe_options: Union[ProfileOptions, Dict]) → pypesto.profile.options.ProfileOptions¶ Returns a valid options object.
 Parameters
maybe_options (ProfileOptions or dict) –

class
pypesto.profile.
ProfilerResult
(x_path: numpy.ndarray, fval_path: numpy.ndarray, ratio_path: numpy.ndarray, gradnorm_path: numpy.ndarray = None, exitflag_path: numpy.ndarray = None, time_path: numpy.ndarray = None, time_total: float = 0.0, n_fval: int = 0, n_grad: int = 0, n_hess: int = 0, message: str = None)¶ Bases:
dict
The result of a profiler run. The standardized return return value from pypesto.profile, which can either be initialized from an OptimizerResult or from an existing ProfilerResult (in order to extend the computation).
Can be used like a dict.

x_path
¶ The path of the best found parameters along the profile (Dimension: n_par x n_profile_points)

fval_path
¶ The function values, fun(x), along the profile.

ratio_path
¶ The ratio of the posterior function along the profile.

gradnorm_path
¶ The gradient norm along the profile.

exitflag_path
¶ The exitflags of the optimizer along the profile.

time_path
¶ The computation time of the optimizer runs along the profile.

time_total
¶ The total computation time for the profile.

n_fval
¶ Number of function evaluations.

n_grad
¶ Number of gradient evaluations.

n_hess
¶ Number of Hessian evaluations.

message
¶ Textual comment on the profile result.
Notes
Any field not supported by the profiler or the profiling optimizer is filled with None. Some fields are filled by pypesto itself.

__init__
(x_path: numpy.ndarray, fval_path: numpy.ndarray, ratio_path: numpy.ndarray, gradnorm_path: numpy.ndarray = None, exitflag_path: numpy.ndarray = None, time_path: numpy.ndarray = None, time_total: float = 0.0, n_fval: int = 0, n_grad: int = 0, n_hess: int = 0, message: str = None)¶ Initialize self. See help(type(self)) for accurate signature.

append_profile_point
(x: numpy.ndarray, fval: float, ratio: float, gradnorm: float = nan, time: float = nan, exitflag: float = nan, n_fval: int = 0, n_grad: int = 0, n_hess: int = 0) → None¶ This function appends a new point to the profile path.
 Parameters
x – The parameter values.
fval – The function value at x.
ratio – The ratio of the function value at x by the optimal function value.
gradnorm – The gradient norm at x.
time – The computation time to find x.
exitflag – The exitflag of the optimizer (useful if an optimization was performed to find x).
n_fval – Number of function evaluations performed to find x.
n_grad – Number of gradient evaluations performed to find x.
n_hess – Number of Hessian evaluations performed to find x.

flip_profile
() → None¶ This function flips the profiling direction (leftright) Profiling direction needs to be changed once (if the profile is new), or twice if we append to an existing profile.
All profiling paths are flipped inplace.


pypesto.profile.
approximate_parameter_profile
(problem: pypesto.problem.Problem, result: pypesto.result.Result, profile_index: Iterable[int] = None, profile_list: int = None, result_index: int = 0, n_steps: int = 100) → pypesto.result.Result¶ Calculate profiles based on an approximation via a normal likelihood centered at the chosen optimal parameter value, with the covariance matrix being the Hessian or FIM.
 Parameters
problem – The problem to be solved.
result – A result object to initialize profiling and to append the profiling results to. For example, one might append more profiling runs to a previous profile, in order to merge these. The existence of an optimization result is obligatory.
profile_index – Array with parameter indices, whether a profile should be computed (1) or not (0). Default is all profiles should be computed.
profile_list – Integer which specifies whether a call to the profiler should create a new list of profiles (default) or should be added to a specific profile list.
result_index – Index from which optimization result profiling should be started (default: global optimum, i.e., index = 0).
n_steps – Number of profile steps in each dimension.
 Returns
The profile results are filled into result.profile_result.
 Return type
result

pypesto.profile.
calculate_approximate_ci
(xs: numpy.ndarray, ratios: numpy.ndarray, confidence_ratio: float) → Tuple[float, float]¶ Calculate approximate confidence interval based on profile. Interval bounds are linerly interpolated.
 Parameters
xs – The ordered parameter values along the profile for the coordinate of interest.
ratios – The likelihood ratios corresponding to the parameter values.
confidence_ratio – Minimum confidence ratio to base the confidence interval upon, as obtained via pypesto.profile.chi2_quantile_to_ratio.
 Returns
Bounds of the approximate confidence interval.
 Return type
lb, ub

pypesto.profile.
chi2_quantile_to_ratio
(alpha: float = 0.95, df: int = 1)¶ Transform lower tail probability alpha for a chi2 distribution with df degrees of freedom to a profile likelihood ratio threshold.
 Parameters
alpha – Lower tail probability, defaults to 95% interval.
df – Degrees of freedom. Defaults to 1.
 Returns
Corresponds to a likelihood ratio.
 Return type
ratio

pypesto.profile.
parameter_profile
(problem: pypesto.problem.Problem, result: pypesto.result.Result, optimizer: pypesto.optimize.optimizer.Optimizer, profile_index: numpy.ndarray = None, profile_list: int = None, result_index: int = 0, next_guess_method: Union[Callable, str] = 'adaptive_step_regression', profile_options: pypesto.profile.options.ProfileOptions = None) → pypesto.result.Result¶ This is the main function to call to do parameter profiling.
 Parameters
problem – The problem to be solved.
result – A result object to initialize profiling and to append the profiling results to. For example, one might append more profiling runs to a previous profile, in order to merge these. The existence of an optimization result is obligatory.
optimizer – The optimizer to be used along each profile.
profile_index – Array with parameter indices, whether a profile should be computed (1) or not (0). Default is all profiles should be computed.
profile_list – Integer which specifies whether a call to the profiler should create a new list of profiles (default) or should be added to a specific profile list.
result_index – Index from which optimization result profiling should be started (default: global optimum, i.e., index = 0).
next_guess_method – Function handle to a method that creates the next starting point for optimization in profiling.
profile_options – Various options applied to the profile optimization.
 Returns
The profile results are filled into result.profile_result.
 Return type
result