Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
BayesValidRox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
inversemodeling
BayesValidRox
Commits
7e4aecd0
Commit
7e4aecd0
authored
2 years ago
by
Farid Mohammadi
Browse files
Options
Downloads
Patches
Plain Diff
fix bugs related to n_bootstrap.
parent
7a0c5e1e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Resolve "Justifiability analysis"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bayesvalidrox/bayes_inference/bayes_model_comparison.py
+7
-9
7 additions, 9 deletions
src/bayesvalidrox/bayes_inference/bayes_model_comparison.py
with
7 additions
and
9 deletions
src/bayesvalidrox/bayes_inference/bayes_model_comparison.py
+
7
−
9
View file @
7e4aecd0
...
@@ -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
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment