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
549dba82
Commit
549dba82
authored
3 months ago
by
kohlhaasrebecca
Browse files
Options
Downloads
Patches
Plain Diff
Add model_out to PostProcessing._plot_validation_multi
parent
aaaa9788
No related branches found
No related tags found
1 merge request
!37
Fix/post processing
Pipeline
#52472
failed
3 months ago
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/bayesvalidrox/post_processing/post_processing.py
+21
-46
21 additions, 46 deletions
src/bayesvalidrox/post_processing/post_processing.py
tests/test_PostProcessing.py
+9
-4
9 additions, 4 deletions
tests/test_PostProcessing.py
with
30 additions
and
50 deletions
src/bayesvalidrox/post_processing/post_processing.py
+
21
−
46
View file @
549dba82
...
@@ -220,16 +220,14 @@ class PostProcessing:
...
@@ -220,16 +220,14 @@ class PostProcessing:
else
:
else
:
n_samples
=
samples
.
shape
[
0
]
n_samples
=
samples
.
shape
[
0
]
if
model_out_dict
is
not
None
:
if
model_out_dict
is
None
:
self
.
model_out_dict
=
model_out_dict
model_out_dict
,
_
=
self
.
engine
.
Model
.
run_model_parallel
(
else
:
self
.
model_out_dict
,
_
=
self
.
engine
.
Model
.
run_model_parallel
(
samples
,
key_str
=
"
valid
"
samples
,
key_str
=
"
valid
"
)
)
out_mean
,
out_std
=
self
.
engine
.
eval_metamodel
(
samples
)
out_mean
,
out_std
=
self
.
engine
.
eval_metamodel
(
samples
)
self
.
_plot_validation_multi
(
out_mean
=
out_mean
,
out_std
=
out_std
)
self
.
_plot_validation_multi
(
out_mean
,
out_std
,
model_out_dict
)
# TODO: should this be kept here?
# TODO: should this be kept here?
# Zip the subdirectories
# Zip the subdirectories
...
@@ -986,48 +984,36 @@ class PostProcessing:
...
@@ -986,48 +984,36 @@ class PostProcessing:
)
)
plt
.
close
(
fig
)
plt
.
close
(
fig
)
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
def
_plot_validation_multi
(
self
,
out_mean
,
out_std
):
def
_plot_validation_multi
(
self
,
out_mean
,
out_std
,
model_out
):
"""
"""
Plots outputs for visual comparison of metamodel outputs with that of
Plots outputs for visual comparison of metamodel outputs with that of
the (full) multioutput original model
the (full) multioutput original model
Parameters
Parameters
----------
----------
x_values : list or array
out_mean : dict
List of x values.
MetaModel mean outputs.
x_axis : str, optional
out_std : dict
Label of the x axis. The default is
"
x [m]
"
.
MetaModel stdev outputs.
model_out : dict
Raises
Model outputs.
------
AttributeError: This evaluation only support PCE-type models!
Returns
Returns
-------
-------
None.
None.
"""
"""
# This function currently only supports PCE/aPCE
if
not
hasattr
(
self
.
engine
.
MetaModel
,
"
meta_model_type
"
):
raise
AttributeError
(
"
This evaluation only support PCE-type models!
"
)
if
self
.
engine
.
MetaModel
.
meta_model_type
.
lower
()
not
in
[
"
pce
"
,
"
apce
"
,
"
gpe
"
]:
raise
AttributeError
(
"
This evaluation only support PCE-type models!
"
)
# List of markers and colors
# List of markers and colors
color
=
cycle
(([
"
b
"
,
"
g
"
,
"
r
"
,
"
y
"
,
"
k
"
]))
color
=
cycle
(([
"
b
"
,
"
g
"
,
"
r
"
,
"
y
"
,
"
k
"
]))
marker
=
cycle
((
"
x
"
,
"
d
"
,
"
+
"
,
"
o
"
,
"
*
"
))
marker
=
cycle
((
"
x
"
,
"
d
"
,
"
+
"
,
"
o
"
,
"
*
"
))
metamod_name
=
self
.
engine
.
MetaModel
.
meta_model_type
.
lower
()
if
self
.
engine
.
MetaModel
.
meta_model_type
.
lower
()
==
"
gpe
"
:
lower
=
"
GPE
"
elif
self
.
engine
.
MetaModel
.
meta_model_type
.
lower
()
==
"
pce
"
or
self
.
engine
.
MetaModel
.
meta_model_type
.
lower
()
==
"
apce
"
:
lower
=
"
PCE
"
# Plot the model vs PCE model
# Plot the model vs PCE model
fig
=
plt
.
figure
()
fig
=
plt
.
figure
()
for
_
,
key
in
enumerate
(
self
.
engine
.
out_names
):
for
_
,
key
in
enumerate
(
self
.
engine
.
out_names
):
y_val
=
out_mean
[
key
]
y_val
=
out_mean
[
key
]
y_val_std
=
out_std
[
key
]
y_val_std
=
out_std
[
key
]
y_val
=
self
.
model_out
_dict
[
key
]
y_val
=
model_out
[
key
]
for
idx
in
range
(
y_val
.
shape
[
0
]):
for
idx
in
range
(
y_val
.
shape
[
0
]):
plt
.
plot
(
plt
.
plot
(
...
@@ -1037,26 +1023,14 @@ class PostProcessing:
...
@@ -1037,26 +1023,14 @@ class PostProcessing:
marker
=
next
(
marker
),
marker
=
next
(
marker
),
label
=
"
$Y_{%s}^M$
"
%
(
idx
+
1
),
label
=
"
$Y_{%s}^M$
"
%
(
idx
+
1
),
)
)
if
self
.
engine
.
MetaModel
.
meta_model_type
.
lower
()
==
"
pce
"
\
plt
.
plot
(
or
self
.
engine
.
MetaModel
.
meta_model_type
.
lower
()
==
"
apce
"
:
self
.
x_values
,
plt
.
plot
(
y_val
[
idx
],
self
.
x_values
,
color
=
next
(
color
),
y_val
[
idx
],
marker
=
next
(
marker
),
color
=
next
(
color
),
linestyle
=
"
--
"
,
marker
=
next
(
marker
),
label
=
"
$Y_{{{}}}^{{{}}}$
"
.
format
(
idx
+
1
,
metamod_name
)
linestyle
=
"
--
"
,
label
=
"
$Y_{{{}}}^{{{}}}$
"
.
format
(
idx
+
1
,
lower
)
)
)
elif
self
.
engine
.
MetaModel
.
meta_model_type
.
lower
()
==
"
gpe
"
:
plt
.
plot
(
self
.
x_values
,
y_val
[
idx
],
color
=
next
(
color
),
marker
=
next
(
marker
),
linestyle
=
"
--
"
,
label
=
"
$Y_{{{}}}^{{{}}}$
"
.
format
(
idx
+
1
,
lower
)
)
plt
.
fill_between
(
plt
.
fill_between
(
self
.
x_values
,
self
.
x_values
,
y_val
[
idx
]
-
1.96
*
y_val_std
[
idx
],
y_val
[
idx
]
-
1.96
*
y_val_std
[
idx
],
...
@@ -1080,6 +1054,7 @@ class PostProcessing:
...
@@ -1080,6 +1054,7 @@ class PostProcessing:
plt
.
grid
()
plt
.
grid
()
key
=
key
.
replace
(
"
"
,
"
_
"
)
key
=
key
.
replace
(
"
"
,
"
_
"
)
fig
.
savefig
(
fig
.
savefig
(
f
"
./
{
self
.
out_dir
}
/Model_vs_
{
lower
}
Model_
{
key
}
.
{
self
.
out_format
}
"
,
bbox_inches
=
"
tight
"
f
"
./
{
self
.
out_dir
}
/Model_vs_
{
metamod_name
}
Model_
{
key
}
.
{
self
.
out_format
}
"
,
bbox_inches
=
"
tight
"
)
)
plt
.
close
()
plt
.
close
()
This diff is collapsed.
Click to expand it.
tests/test_PostProcessing.py
+
9
−
4
View file @
549dba82
...
@@ -417,11 +417,16 @@ def test_plot_validation_multi(pce_engine_3d_plot):
...
@@ -417,11 +417,16 @@ def test_plot_validation_multi(pce_engine_3d_plot):
"""
"""
engine
=
pce_engine_3d_plot
engine
=
pce_engine_3d_plot
post
=
PostProcessing
(
engine
)
post
=
PostProcessing
(
engine
)
y_val
=
{
'
Z
'
:
[
1
,
2
,
3
,
4
,
5
]}
y_val
=
{
'
Z
'
:
np
.
array
([[
1
],
[
2
],
[
3
],
[
4
],
[
5
]]),
y_val_std
=
{
'
Z
'
:
[
0.1
,
0.2
,
0.3
,
0.4
,
0.5
]}
'
Y
'
:
np
.
array
([[
1
],
[
2
],
[
3
],
[
4
],
[
5
]])}
post
.
_plot_validation_multi
(
y_val
,
y_val_std
)
y_val_std
=
{
'
Z
'
:
np
.
array
([[
0.1
],
[
0.2
],
[
0.3
],
[
0.4
],
[
0.5
]]),
'
Y
'
:
np
.
array
([[
0.1
],
[
0.2
],
[
0.3
],
[
0.4
],
[
0.5
]])}
model_out
=
{
'
Z
'
:
np
.
array
([[
1.5
],[
2
],[
3.5
],[
4
],[
4.5
]]),
'
Y
'
:
np
.
array
([[
1.5
],[
2
],[
3.5
],[
4
],[
4.5
]])}
post
.
_plot_validation_multi
(
y_val
,
y_val_std
,
model_out
)
# Check if the plot was created and saved
# Check if the plot was created and saved
assert
os
.
path
.
exists
(
f
"
./
{
engine
.
out_dir
}
/Model_vs_Model_key1.
{
engine
.
out_format
}
"
)
assert
os
.
path
.
exists
(
f
"
./
{
post
.
out_dir
}
/Model_vs_pceModel_Y.
{
post
.
out_format
}
"
)
assert
os
.
path
.
exists
(
f
"
./
{
post
.
out_dir
}
/Model_vs_pceModel_Z.
{
post
.
out_format
}
"
)
def
test_plot_validation_multi_with_multiple_keys
(
pce_engine_3d_plot
):
def
test_plot_validation_multi_with_multiple_keys
(
pce_engine_3d_plot
):
"""
"""
...
...
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