Skip to content
Snippets Groups Projects
Commit 7e4aecd0 authored by Farid Mohammadi's avatar Farid Mohammadi
Browse files

fix bugs related to n_bootstrap.

parent 7a0c5e1e
No related branches found
No related tags found
1 merge request!1Resolve "Justifiability analysis"
...@@ -38,7 +38,7 @@ class BayesModelComparison: ...@@ -38,7 +38,7 @@ class BayesModelComparison:
) )
output = { output = {
'Bayes factor': bayes_dict_bf, 'Bayes objects BF': bayes_dict_bf,
'Model weights BF': model_weights_dict_bf 'Model weights BF': model_weights_dict_bf
} }
...@@ -48,7 +48,7 @@ class BayesModelComparison: ...@@ -48,7 +48,7 @@ class BayesModelComparison:
model_dict, opts_dict, justifiability=True model_dict, opts_dict, justifiability=True
) )
output['Justifiability analysis'] = bayes_dict_ja output['Bayes objects JA'] = bayes_dict_ja
output['Model weights JA'] = model_weights_dict_ja output['Model weights JA'] = model_weights_dict_ja
return output return output
...@@ -70,12 +70,11 @@ class BayesModelComparison: ...@@ -70,12 +70,11 @@ class BayesModelComparison:
# ----- Generate data ----- # ----- Generate data -----
# Find n_bootstrap # Find n_bootstrap
if not justifiability: if self.perturbed_data is None:
n_bootstarp = self.n_bootstarp n_bootstarp = self.n_bootstarp
else: else:
# find the smallest n_samples n_bootstarp = self.perturbed_data.shape[0]
n_bootstarp = min([len(MetaModel.ExpDesign.X) for MetaModel
in modelDict.values()])
# Create dataset # Create dataset
justData = self.generate_dataset( justData = self.generate_dataset(
modelDict, justifiability, n_bootstarp=n_bootstarp) modelDict, justifiability, n_bootstarp=n_bootstarp)
...@@ -106,7 +105,7 @@ class BayesModelComparison: ...@@ -106,7 +105,7 @@ class BayesModelComparison:
# Compute model weights # Compute model weights
BME_Dict = dict() BME_Dict = dict()
for modelName, bayesObj in bayesDict.items(): for modelName, bayesObj in bayesDict.items():
BME_Dict[modelName] = np.exp(bayesObj.log_BME) BME_Dict[modelName] = np.exp(bayesObj.log_BME, dtype=np.float128)
# BME correction in BayesInference class # BME correction in BayesInference class
model_weights = self.cal_modelWeight( model_weights = self.cal_modelWeight(
...@@ -169,8 +168,7 @@ class BayesModelComparison: ...@@ -169,8 +168,7 @@ class BayesModelComparison:
# Use surrogate runs for data-generating process # Use surrogate runs for data-generating process
for key, metaModel in modelDict.items(): for key, metaModel in modelDict.items():
model_data = np.array( model_data = np.array(
[runs[key][out][i] for out in out_names] [runs[key][out][i] for out in out_names]).reshape(y_data.shape)
).reshape(y_data.shape)
justData = np.vstack(( justData = np.vstack((
justData, justData,
np.tril(np.repeat(model_data, model_data.shape[1], axis=0)) np.tril(np.repeat(model_data, model_data.shape[1], axis=0))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment