bayesvalidrox.post_processing.post_processing.PostProcessing¶
- class bayesvalidrox.post_processing.post_processing.PostProcessing(engine, name='calib')¶
Bases:
object
This class provides many helper functions to post-process the trained meta-model.
Attributes¶
- MetaModelobj
MetaModel object to do postprocessing on.
- namestr
Type of the anaylsis. The default is ‘calib’. If a validation is expected to be performed change this to ‘valid’.
- __init__(engine, name='calib')¶
Methods
__init__
(engine[, name])check_accuracy
([n_samples, samples, outputs])Checks accuracy of the metamodel by computing the root mean square error and validation error for all outputs.
check_reg_quality
([n_samples, samples])Checks the quality of the metamodel for single output models based on: https://towardsdatascience.com/how-do-you-check-the-quality-of-your-regression-model-in-python-fa61759ff685
Computes the first two moments using the PCE-based meta-model.
eval_pce_model_3d
()plot_moments
([xlabel, plot_type])Plots the moments in a pdf format in the directory Outputs_PostProcessing.
plot_seq_design_diagnostics
([ref_BME_KLD])Plots the Bayesian Model Evidence (BME) and Kullback-Leibler divergence (KLD) for the sequential design.
sobol_indices
([xlabel, plot_type])Provides Sobol indices as a sensitivity measure to infer the importance of the input parameters.
valid_metamodel
([n_samples, samples, ...])Evaluates and plots the meta model and the PCEModel outputs for the given number of samples or the given samples.
- check_accuracy(n_samples=None, samples=None, outputs=None)¶
Checks accuracy of the metamodel by computing the root mean square error and validation error for all outputs.
Parameters¶
- n_samplesint, optional
Number of samples. The default is None.
- samplesarray of shape (n_samples, n_params), optional
Parameter sets to be checked. The default is None.
- outputsdict, optional
Output dictionary with model outputs for all given output types in Model.Output.names. The default is None.
Raises¶
- Exception
When neither n_samples nor samples are provided.
Returns¶
- rmse: dict
Root mean squared error for each output.
- valid_errordict
Validation error for each output.
- check_reg_quality(n_samples=1000, samples=None)¶
Checks the quality of the metamodel for single output models based on: https://towardsdatascience.com/how-do-you-check-the-quality-of-your-regression-model-in-python-fa61759ff685
Parameters¶
- n_samplesint, optional
Number of parameter sets to use for the check. The default is 1000.
- samplesarray of shape (n_samples, n_params), optional
Parameter sets to use for the check. The default is None.
Returns¶
None.
- compute_pce_moments()¶
Computes the first two moments using the PCE-based meta-model.
Returns¶
- pce_means: dict
The first moments (mean) of outpust.
- pce_means: dict
The first moments (mean) of outpust.
- plot_moments(xlabel='Time [s]', plot_type=None)¶
Plots the moments in a pdf format in the directory Outputs_PostProcessing.
Parameters¶
- xlabelstr, optional
String to be displayed as x-label. The default is ‘Time [s]’.
- plot_typestr, optional
Options: bar or line. The default is None.
Returns¶
- pce_means: dict
Mean of the model outputs.
- pce_means: dict
Standard deviation of the model outputs.
- plot_seq_design_diagnostics(ref_BME_KLD=None)¶
Plots the Bayesian Model Evidence (BME) and Kullback-Leibler divergence (KLD) for the sequential design.
Parameters¶
- ref_BME_KLDarray, optional
Reference BME and KLD . The default is None.
Returns¶
None.
- sobol_indices(xlabel='Time [s]', plot_type=None)¶
Provides Sobol indices as a sensitivity measure to infer the importance of the input parameters. See Eq. 27 in [1] for more details. For the case with Principal component analysis refer to [2].
[1] Global sensitivity analysis: A flexible and efficient framework with an example from stochastic hydrogeology S. Oladyshkin, F.P. de Barros, W. Nowak https://doi.org/10.1016/j.advwatres.2011.11.001
[2] Nagel, J.B., Rieckermann, J. and Sudret, B., 2020. Principal component analysis and sparse polynomial chaos expansions for global sensitivity analysis and model calibration: Application to urban drainage simulation. Reliability Engineering & System Safety, 195, p.106737.
Parameters¶
- xlabelstr, optional
Label of the x-axis. The default is ‘Time [s]’.
- plot_typestr, optional
Plot type. The default is None. This corresponds to line plot. Bar chart can be selected by bar.
Returns¶
- sobol_cell: dict
Sobol indices.
- total_sobol: dict
Total Sobol indices.
- valid_metamodel(n_samples=1, samples=None, model_out_dict=None, x_axis='Time [s]')¶
Evaluates and plots the meta model and the PCEModel outputs for the given number of samples or the given samples.
Parameters¶
- n_samplesint, optional
Number of samples to be evaluated. The default is 1.
- samplesarray of shape (n_samples, n_params), optional
Samples to be evaluated. The default is None.
- model_out_dict: dict
The model runs using the samples provided.
- x_axisstr, optional
Label of x axis. The default is ‘Time [s]’.
Returns¶
None.