bayesvalidrox.bayes_inference.bayes_model_comparison.BayesModelComparison¶
- class bayesvalidrox.bayes_inference.bayes_model_comparison.BayesModelComparison(justifiability=True, perturbed_data=None, n_bootstrap=1000, data_noise_level=0.01, use_Bayes_settings=True, emulator=True, out_dir='Outputs_Comparison/')¶
Bases:
object
A class to perform Bayesian Analysis.
Attributes¶
- justifiabilitybool, optional
Whether to perform the justifiability analysis. The default is True.
- perturbed_dataarray of shape (n_bootstrap_itrs, n_obs), optional
User defined perturbed data. The default is None.
- n_bootstrapint
Number of bootstrap iteration. The default is 1000.
- data_noise_levelfloat
A noise level to perturb the data set. The default is 0.01.
- __init__(justifiability=True, perturbed_data=None, n_bootstrap=1000, data_noise_level=0.01, use_Bayes_settings=True, emulator=True, out_dir='Outputs_Comparison/')¶
Methods
__init__
([justifiability, perturbed_data, ...])cal_model_weight
(BME_dict[, justifiability, ...])Normalize the BME (Asumption: Model Prior weights are equal for models)
calc_bayes_factors
(model_dict, opts_dict)Calculate the BayesFactors for each pair of models in the model_dict with respect to given data.
calc_justifiability_analysis
(model_dict, ...)Perform justifiability analysis by calculating the confusion matrix
calc_model_weights
(model_dict, opts_dict)Calculate the model weights from BME evaluations for Bayes factors.
generate_dataset
(model_dict[, ...])Generates the perturbed data set for the Bayes factor calculations and the data set for the justifiability analysis.
model_comparison_all
(model_dict, opts_dict)Perform all three types of model comparison:
plot_bayes_factor
(BME_dict[, plot_name])Plots the Bayes factor distibutions in a \(N_m \times N_m\) matrix, where \(N_m\) is the number of the models.
Visualizes the confusion matrix and the model wights for the justifiability analysis.
plot_model_weights
(model_weights, plot_name)Visualizes the model weights resulting from BMS via the observation data.
setup
(model_dict)Initialize parameters that are needed for all types of model comparison
- cal_model_weight(BME_dict, justifiability=False, n_bootstrap=1)¶
Normalize the BME (Asumption: Model Prior weights are equal for models)
Parameters¶
- BME_dictdict
A dictionary containing the BME values.
Returns¶
- model_weightsarray
Model weights.
- calc_bayes_factors(model_dict, opts_dict)¶
Calculate the BayesFactors for each pair of models in the model_dict with respect to given data.
Parameters¶
- model_dictdict
A dictionary including the metamodels.
- opts_dictdict
A dictionary given the BayesInference options.
Returns¶
None.
- calc_justifiability_analysis(model_dict, opts_dict)¶
Perform justifiability analysis by calculating the confusion matrix
Parameters¶
- model_dictdict
A dictionary including the metamodels.
- opts_dictdict
A dictionary given the BayesInference options.
Returns¶
- confusion_matrix: dict
The averaged confusion matrix
- calc_model_weights(model_dict, opts_dict)¶
Calculate the model weights from BME evaluations for Bayes factors.
Parameters¶
- model_dictTYPE
DESCRIPTION.
- opts_dictTYPE
DESCRIPTION.
Returns¶
None.
- generate_dataset(model_dict, justifiability=False, n_bootstrap=1)¶
Generates the perturbed data set for the Bayes factor calculations and the data set for the justifiability analysis.
Parameters¶
- model_dictdict
A dictionary including the metamodels.
- bool, optional
Whether to perform the justifiability analysis. The default is False.
- n_bootstrapint, optional
Number of bootstrap iterations. The default is 1.
Returns¶
- all_just_data: array
Created data set.
- model_comparison_all(model_dict, opts_dict)¶
- Perform all three types of model comparison:
Bayes Factors
Model weights
Justifiability analysis
Parameters¶
- model_dictdict
A dictionary including the metamodels.
- opts_dictdict
A dictionary given the BayesInference options.
Returns¶
- resultsdict
A dictionary that contains the calculated BME values, model weights and confusion matrix
- plot_bayes_factor(BME_dict, plot_name='')¶
Plots the Bayes factor distibutions in a \(N_m \times N_m\) matrix, where \(N_m\) is the number of the models.
Parameters¶
- BME_dictdict
A dictionary containing the BME values of the models.
- plot_namestr, optional
Plot name. The default is ‘’.
Returns¶
None.
- plot_just_analysis()¶
Visualizes the confusion matrix and the model wights for the justifiability analysis.
Parameters¶
- model_weights_dictdict
Model weights.
Returns¶
None.