Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
machine-learning
MLAir
Commits
3eb4745c
Commit
3eb4745c
authored
Feb 26, 2020
by
lukas leufen
Browse files
Options
Downloads
Patches
Plain Diff
save orig labels locally
parent
cf202273
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!59
Develop
,
!52
implemented bootstraps
Pipeline
#30529
passed
Feb 26, 2020
Stage: test
Stage: pages
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/data_handling/bootstraps.py
+15
-0
15 additions, 0 deletions
src/data_handling/bootstraps.py
src/run_modules/post_processing.py
+9
-3
9 additions, 3 deletions
src/run_modules/post_processing.py
with
24 additions
and
3 deletions
src/data_handling/bootstraps.py
+
15
−
0
View file @
3eb4745c
...
...
@@ -31,6 +31,11 @@ class BootStrapGenerator:
"""
return
len
(
self
.
orig_generator
)
*
self
.
boots
*
len
(
self
.
variables
)
def
get_labels
(
self
):
for
(
_
,
label
)
in
self
.
orig_generator
:
for
_
in
range
(
self
.
boots
):
yield
label
def
get_generator
(
self
):
"""
This is the implementation of the __next__ method of the iterator protocol. Get the data generator, and return
...
...
@@ -85,6 +90,16 @@ class BootStraps(RunEnvironment):
def
get_boot_strap_generator_length
(
self
):
return
self
.
_boot_strap_generator
.
__len__
()
def
get_labels
(
self
):
labels_list
=
[]
chunks
=
None
for
labels
in
self
.
_boot_strap_generator
.
get_labels
():
if
len
(
labels_list
)
==
0
:
chunks
=
(
100
,
labels
.
data
.
shape
[
1
])
labels_list
.
append
(
da
.
from_array
(
labels
.
data
,
chunks
=
chunks
))
labels_out
=
da
.
concatenate
(
labels_list
,
axis
=
0
)
return
labels_out
.
compute
()
def
get_chunk_size
(
self
):
hist
,
_
=
self
.
data
[
0
]
return
(
100
,
*
hist
.
shape
[
1
:],
self
.
number_bootstraps
)
...
...
This diff is collapsed.
Click to expand it.
src/run_modules/post_processing.py
+
9
−
3
View file @
3eb4745c
...
...
@@ -49,15 +49,15 @@ class PostProcessing(RunEnvironment):
self
.
make_prediction
()
logging
.
info
(
"
take a look on the next reported time measure. If this increases a lot, one should think to
"
"
skip make_prediction() whenever it is possible to save time.
"
)
self
.
skill_scores
=
self
.
calculate_skill_scores
()
self
.
plot
()
#
self.skill_scores = self.calculate_skill_scores()
#
self.plot()
self
.
create_boot_straps
()
def
create_boot_straps
(
self
):
bootstrap_path
=
self
.
data_store
.
get
(
"
bootstrap_path
"
,
"
general
"
)
forecast_path
=
self
.
data_store
.
get
(
"
forecast_path
"
,
"
general
"
)
window_lead_time
=
self
.
data_store
.
get
(
"
window_lead_time
"
,
"
general
"
)
bootstraps
=
BootStraps
(
self
.
test_data
,
bootstrap_path
,
2
0
)
bootstraps
=
BootStraps
(
self
.
test_data
,
bootstrap_path
,
2
)
with
TimeTracking
(
name
=
"
boot predictions
"
):
bootstrap_predictions
=
self
.
model
.
predict_generator
(
generator
=
bootstraps
.
boot_strap_generator
(),
steps
=
bootstraps
.
get_boot_strap_generator_length
())
...
...
@@ -68,8 +68,14 @@ class PostProcessing(RunEnvironment):
ind
=
(
bootstrap_meta
==
boot
)
sel
=
bootstrap_predictions
[
ind
].
reshape
((
length
,
window_lead_time
,
1
))
tmp
=
xr
.
DataArray
(
sel
,
coords
=
(
range
(
length
),
range
(
window_lead_time
),
[
boot
]),
dims
=
[
"
index
"
,
"
window
"
,
"
boot
"
])
logging
.
info
(
tmp
.
shape
)
file_name
=
os
.
path
.
join
(
forecast_path
,
f
"
bootstraps_
{
boot
}
.nc
"
)
tmp
.
to_netcdf
(
file_name
)
labels
=
bootstraps
.
get_labels
().
reshape
((
length
,
window_lead_time
,
1
))
file_name
=
os
.
path
.
join
(
forecast_path
,
f
"
bootstraps_orig.nc
"
)
orig
=
xr
.
DataArray
(
labels
,
coords
=
(
range
(
length
),
range
(
window_lead_time
),
[
"
orig
"
]),
dims
=
[
"
index
"
,
"
window
"
,
"
boot
"
])
logging
.
info
(
orig
.
shape
)
orig
.
to_netcdf
(
file_name
)
def
_load_model
(
self
):
try
:
...
...
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