pypesto.result
Result
The pypesto.Result object contains all results generated by the pypesto components. It contains sub-results for optimization, profiling, sampling.
- class pypesto.result.LazyOptimizerResult[source]
Bases:
OptimizerResult
A class to handle lazy loading of optimizer results from an HDF5 file.
This class extends the OptimizerResult class and overrides methods to load data only when it is accessed, improving memory usage and performance for large datasets.
- property exitflag
See
OptimizerResult
.
- property free_indices
See
OptimizerResult
.
- property fval
See
OptimizerResult
.
- property fval0
See
OptimizerResult
.
- property grad
See
OptimizerResult
.
- property hess
See
OptimizerResult
.
- property history
See
OptimizerResult
.
- property id
See
OptimizerResult
.
- property inner_parameters
See
OptimizerResult
.
- property message
See
OptimizerResult
.
- property n_fval
See
OptimizerResult
.
- property n_grad
See
OptimizerResult
.
- property n_hess
See
OptimizerResult
.
- property n_res
See
OptimizerResult
.
- property n_sres
See
OptimizerResult
.
- property optimizer
See
OptimizerResult
.
- property res
See
OptimizerResult
.
- property spline_knots
See
OptimizerResult
.
- property sres
See
OptimizerResult
.
- property time
See
OptimizerResult
.
- property x
See
OptimizerResult
.
- property x0
See
OptimizerResult
.
- class pypesto.result.McmcPtResult[source]
Bases:
dict
The result of a sampler run using Markov-chain Monte Carlo.
Currently result object of all supported samplers. Can be used like a dict.
- Parameters:
trace_x ([n_chain, n_iter, n_par]) – Parameters.
trace_neglogpost ([n_chain, n_iter]) – Negative log posterior values.
trace_neglogprior ([n_chain, n_iter]) – Negative log prior values.
betas ([n_chain]) – The associated inverse temperatures.
burn_in ([n_chain]) – The burn in index.
time ([n_chain]) – The computation time.
auto_correlation ([n_chain]) – The estimated chain autcorrelation.
effective_sample_size ([n_chain]) – The estimated effective sample size.
message (str) – Textual comment on the profile result.
Here
chains (n_chain denotes the number of)
of (n_iter the number)
(i.e. (iterations)
length) (the chain)
parameters. (and n_par the number of)
- class pypesto.result.OptimizeResult[source]
Bases:
object
Result of the
pypesto.optimize.minimize()
function.- append(optimize_result, sort=True, prefix='')[source]
Append an OptimizerResult or an OptimizeResult to the result object.
- Parameters:
optimize_result (
Union
[OptimizerResult
,OptimizeResult
]) – The result of one or more (local) optimizer run.sort (
bool
) – Boolean used so we only sort once when appending an optimize_result.prefix (
str
) – The IDs for all appended results will be prefixed with this.
- as_dataframe(keys=None)[source]
Get as pandas DataFrame.
If keys is a list, return only the specified values, otherwise all.
- Return type:
- class pypesto.result.OptimizerResult[source]
Bases:
dict
The result of an optimizer run.
Used as a standardized return value to map from the individual result objects returned by the employed optimizers to the format understood by pypesto.
Can be used like a dict.
- id
Id of the optimizer run. Usually the start index.
- x
The best found parameters.
- fval
The best found function value, fun(x).
- grad
The gradient at x.
- hess
The Hessian at x.
- res
The residuals at x.
- sres
The residual sensitivities at x.
- n_fval
Number of function evaluations.
- n_grad
Number of gradient evaluations.
- n_hess
Number of Hessian evaluations.
- n_res
Number of residuals evaluations.
- n_sres
Number of residual sensitivity evaluations.
- x0
The starting parameters.
- fval0
The starting function value, fun(x0).
- history
Objective history.
- exitflag
The exitflag of the optimizer.
- time
Execution time.
Notes
Any field not supported by the optimizer is filled with None.
- __init__(id=None, x=None, fval=None, grad=None, hess=None, res=None, sres=None, n_fval=None, n_grad=None, n_hess=None, n_res=None, n_sres=None, x0=None, fval0=None, history=None, exitflag=None, time=None, message=None, optimizer=None)[source]
- class pypesto.result.PredictionConditionResult[source]
Bases:
object
Light-weight wrapper for the prediction of one simulation condition.
It should provide a common api how amici predictions should look like in pyPESTO.
- __init__(timepoints, output_ids, output=None, output_sensi=None, output_weight=None, output_sigmay=None, x_names=None)[source]
Initialize PredictionConditionResult.
- Parameters:
timepoints (
ndarray
) – Output timepoints for this simulation conditionoutput_ids (
Sequence
[str
]) – IDs of outputs for this simulation conditionoutput (
ndarray
) – Postprocessed outputs (ndarray)output_sensi (
ndarray
) – Sensitivities of postprocessed outputs (ndarray)output_weight (
float
) – LLH of the simulationoutput_sigmay (
ndarray
) – Standard deviations of postprocessed observablesx_names (
Sequence
[str
]) – IDs of model parameter w.r.t to which sensitivities were computed
- class pypesto.result.PredictionResult[source]
Bases:
object
Light-weight wrapper around prediction from pyPESTO made by an AMICI model.
Its only purpose is to have fixed format/api, how prediction results should be stored, read, and handled: as predictions are a very flexible format anyway, they should at least have a common definition, which allows to work with them in a reasonable way.
- __init__(conditions, condition_ids=None, comment=None)[source]
Initialize PredictionResult.
- Parameters:
conditions (
Sequence
[Union
[PredictionConditionResult
,dict
]]) – A list of PredictionConditionResult objects or dictscondition_ids (
Sequence
[str
]) – IDs or names of the simulation conditions, which belong to this prediction (e.g., PEtab uses tuples of preequilibration condition and simulation conditions)comment (
str
) – An additional note, which can be attached to this prediction
- class pypesto.result.ProfileResult[source]
Bases:
object
Result of the profile() function.
It holds a list of profile lists. Each profile list consists of a list of ProfilerResult objects, one for each parameter.
- append_empty_profile_list()[source]
Append an empty profile list to the list of profile lists.
- Return type:
- Returns:
index – The index of the created profile list.
- append_profiler_result(profiler_result=None, profile_list=None)[source]
Append the profiler result to the profile list.
- Parameters:
profiler_result (
ProfilerResult
) – The result of one profiler run for a parameter, or None if to be left empty.profile_list (
int
) – Index specifying the profile list to which we want to append. Defaults to the last list.
- Return type:
- get_profiler_result(i_par, profile_list=None)[source]
Get the profiler result at parameter index i_par of profile_list.
- set_profiler_result(profiler_result, i_par, profile_list=None)[source]
Write a profiler result to the result object.
- Parameters:
profiler_result (
ProfilerResult
) – The result of one (local) profiler run.i_par (
int
) – Integer specifying the parameter index where to put profiler_result.profile_list (
int
) – Index specifying the profile list. Defaults to the last list.
- Return type:
- class pypesto.result.ProfilerResult[source]
Bases:
dict
The result of a profiler run.
The standardized 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.
- color_path
The color of the profile path. Signifies types of steps made. Red indicates a step for which min_step_size was reduced, blue indicates a step for which max_step_size was increased, and green indicates a step for which the profiler had to resample the parameter vector due to optimization failure of the previous two. Black indicates a step for which none of the above was necessary.
- 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, fval_path, ratio_path, gradnorm_path=None, exitflag_path=None, time_path=None, color_path=None, time_total=0.0, n_fval=0, n_grad=0, n_hess=0, message=None)[source]
- append_profile_point(x, fval, ratio, gradnorm=nan, time=nan, color=nan, exitflag=nan, n_fval=0, n_grad=0, n_hess=0)[source]
Append a new point to the profile path.
- Parameters:
x (
ndarray
) – The parameter values.fval (
float
) – The function value at x.ratio (
float
) – The ratio of the function value at x by the optimal function value.gradnorm (
float
) – The gradient norm at x.time (
float
) – The computation time to find x.color (
ndarray
) – The color of the profile path. Signifies types of steps made.exitflag (
float
) – The exitflag of the optimizer (useful if an optimization was performed to find x).n_fval (
int
) – Number of function evaluations performed to find x.n_grad (
int
) – Number of gradient evaluations performed to find x.n_hess (
int
) – Number of Hessian evaluations performed to find x.
- Return type:
- class pypesto.result.Result[source]
Bases:
object
Universal result object for pypesto.
The algorithms like optimize, profile, sample fill different parts of it.
- problem
The problem underlying the results.
- Type:
pypesto.Problem
- optimize_result
The results of the optimizer runs.
- profile_result
The results of the profiler run.
- sample_result
The results of the sampler run.
- __init__(problem=None, optimize_result=None, profile_result=None, sample_result=None)[source]
- Parameters:
optimize_result (OptimizeResult)
profile_result (ProfileResult)
sample_result (SampleResult)