bayesvalidrox.post_processing.post_processing.PostProcessing¶
- class bayesvalidrox.post_processing.post_processing.PostProcessing(engine, name='calib', out_dir='', out_format='pdf')¶
Bases:
object
This class provides post-processing functions for the trained metamodels.
Parameters¶
- engineobj
Trained Engine object, is expected to contain a trained MetaModel object.
- namestring
Name of the PostProcessing object to be used for saving the generated files. The default is ‘calib’.
- out_dirstring
Output directory in which the PostProcessing results are placed. The results are contained in a subfolder ‘/Outputs_PostProcessing_name’ The default is ‘’.
- out_formatstring
Format of the saved plots. Supports ‘png’ and ‘pdf’. The default is ‘pdf’.
Raises¶
- AttributeError
engine must be trained.
- __init__(engine, name='calib', out_dir='', out_format='pdf')¶
Methods
__init__
(engine[, name, out_dir, out_format])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, outputs])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
plot_metamodel_3d
([n_samples])Visualize the results of a MetaModel as a 3D surface over two input parameters.
plot_moments
([plot_type])Plots the moments in a user defined output format (standard is pdf) 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.
plot_sobol
(par_names, outputs[, sobol_type, ...])Generate plots for each output in the given set of Sobol' indices.
sobol_indices
([plot_type, save])Visualizes and writes out Sobol' and Total Sobol' indices of the trained metamodel.
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) 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 engine.out_names. The default is None.
Raises¶
- AttributeError
When neither n_samples nor samples are provided.
Returns¶
None
- check_reg_quality(n_samples: int = 1000, samples=None, outputs: dict | None = None) 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.
- outputsdict, optional
Output dictionary with model outputs for all given output types in engine.out_names. The default is None.
Returns¶
None
- plot_metamodel_3d(n_samples=10)¶
Visualize the results of a MetaModel as a 3D surface over two input parameters.
Parameters¶
- n_samplesint
Number of samples that are used to generate the 3D plot.
Raises¶
- AttributeError
This function is only applicable if the MetaModel input dimension is 2.
Returns¶
None
- plot_moments(plot_type: str = 'line')¶
Plots the moments in a user defined output format (standard is pdf) in the directory Outputs_PostProcessing.
Parameters¶
- plot_typestr, optional
Supports ‘bar’ for barplots and ‘line’ for lineplots The default is line.
Raises¶
- AttributeError
Plot type must be ‘bar’ or ‘line’.
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) 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
- plot_sobol(par_names: list, outputs: list, sobol_type: str = 'sobol', i_order: int = 0) None ¶
Generate plots for each output in the given set of Sobol’ indices.
Parameters¶
- par_nameslist
Parameter names for each Sobol’ index.
- outputslist
Output names to be plotted.
- sobol_typestring, optional
Type of Sobol’ indices to visualize. Can be either ‘sobol’ or ‘totalsobol’. The default is ‘sobol’.
- i_orderint, optional
Order of Sobol’ index that should be plotted. This parameter is only applied for sobol_type = ‘sobol’. The default is 0.
Returns¶
None
- sobol_indices(plot_type: str = 'line', save: bool = True)¶
Visualizes and writes out Sobol’ and Total Sobol’ indices of the trained metamodel. One file is created for each index and output key.
Parameters¶
- plot_typestr, optional
Plot type, supports ‘line’ for lineplots and ‘bar’ for barplots. The default is line. Bar chart can be selected by bar.
- savebool, optional
Write out the inidces as csv files if set to True. The default is True.
Raises¶
- AttributeError
MetaModel in given Engine needs to be of type ‘pce’ or ‘apce’.
- AttributeError
Plot-type must be ‘line’ or ‘bar’.
Returns¶
- sobol_alldict
All possible Sobol’ indices for the given metamodel.
- total_sobol_alldict
All Total Sobol’ indices for the given metamodel.
- valid_metamodel(n_samples=1, samples=None, model_out_dict=None) None ¶
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.
Returns¶
None