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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
machine-learning
MLAir
Commits
8bf45b43
Commit
8bf45b43
authored
3 years ago
by
v.gramlich1
Browse files
Options
Downloads
Patches
Plain Diff
Oversampling Plots combined in PlotOversampling method
parent
4ef91f30
No related branches found
No related tags found
1 merge request
!302
Draft: Resolve "Class-based Oversampling technique"
Pipeline
#73227
failed
3 years ago
Stage: test
Stage: docs
Stage: pages
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mlair/plotting/data_insight_plotting.py
+23
-43
23 additions, 43 deletions
mlair/plotting/data_insight_plotting.py
mlair/run_modules/post_processing.py
+2
-10
2 additions, 10 deletions
mlair/run_modules/post_processing.py
with
25 additions
and
53 deletions
mlair/plotting/data_insight_plotting.py
+
23
−
43
View file @
8bf45b43
...
@@ -20,70 +20,50 @@ from mlair.helpers import TimeTrackingWrapper, to_list
...
@@ -20,70 +20,50 @@ from mlair.helpers import TimeTrackingWrapper, to_list
from
mlair.plotting.abstract_plot_class
import
AbstractPlotClass
from
mlair.plotting.abstract_plot_class
import
AbstractPlotClass
@TimeTrackingWrapper
@TimeTrackingWrapper
class
PlotOversampling
Histogram
(
AbstractPlotClass
):
class
PlotOversampling
(
AbstractPlotClass
):
def
__init__
(
self
,
Y
,
Y_extreme
,
bin_edges
,
plot_folder
:
str
=
"
.
"
,
def
__init__
(
self
,
Y
,
Y_extreme
,
bin_edges
,
oversampling_rates
,
plot_folder
:
str
=
"
.
"
,
plot_name
=
"
oversampling_histogram
"
):
plot_names
=
[
"
oversampling_histogram
"
,
"
oversampling_density_histogram
"
,
"
oversampling_rates
"
,
"
oversampling_rates_deviation
"
]):
super
().
__init__
(
plot_folder
,
plot_name
)
super
().
__init__
(
plot_folder
,
plot_names
[
0
])
self
.
_plot
(
Y
,
Y_extreme
,
bin_edges
)
Y_hist
,
Y_extreme_hist
=
self
.
_plot_oversampling_histogram
(
Y
,
Y_extreme
,
bin_edges
)
real_oversampling
=
Y_extreme_hist
/
Y_hist
self
.
_save
()
self
.
plot_name
=
plot_names
[
1
]
self
.
_plot_oversampling_density_histogram
(
Y
,
Y_extreme
,
bin_edges
)
self
.
_save
()
self
.
plot_name
=
plot_names
[
2
]
self
.
_plot_oversampling_rates
(
oversampling_rates
,
real_oversampling
)
self
.
_save
()
self
.
plot_name
=
plot_names
[
3
]
self
.
_plot_oversampling_rates_deviation
(
oversampling_rates
,
real_oversampling
)
self
.
_save
()
self
.
_save
()
def
_plot
(
self
,
Y
,
Y_extreme
,
bin_edges
):
def
_plot
_oversampling_histogram
(
self
,
Y
,
Y_extreme
,
bin_edges
):
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
Y
.
plot
.
hist
(
bins
=
bin_edges
,
histtype
=
"
step
"
,
label
=
"
Before
"
,
ax
=
ax
)[
0
]
Y_hist
=
Y
.
plot
.
hist
(
bins
=
bin_edges
,
histtype
=
"
step
"
,
label
=
"
Before
"
,
ax
=
ax
)[
0
]
Y_extreme
.
plot
.
hist
(
bins
=
bin_edges
,
histtype
=
"
step
"
,
label
=
"
After
"
,
ax
=
ax
)[
0
]
Y_extreme_hist
=
Y_extreme
.
plot
.
hist
(
bins
=
bin_edges
,
histtype
=
"
step
"
,
label
=
"
After
"
,
ax
=
ax
)[
0
]
ax
.
set_title
(
f
"
Histogram before-after oversampling
"
)
ax
.
set_title
(
f
"
Histogram before-after oversampling
"
)
ax
.
legend
()
ax
.
legend
()
return
Y_hist
,
Y_extreme_hist
def
_plot_oversampling_density_histogram
(
self
,
Y
,
Y_extreme
,
bin_edges
):
@TimeTrackingWrapper
class
PlotOversamplingDensityHistogram
(
AbstractPlotClass
):
def
__init__
(
self
,
Y
,
Y_extreme
,
bin_edges
,
plot_folder
:
str
=
"
.
"
,
plot_name
=
"
oversampling_density_histogram
"
):
super
().
__init__
(
plot_folder
,
plot_name
)
self
.
_plot
(
Y
,
Y_extreme
,
bin_edges
)
self
.
_save
()
def
_plot
(
self
,
Y
,
Y_extreme
,
bin_edges
):
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
Y
.
plot
.
hist
(
bins
=
bin_edges
,
density
=
True
,
histtype
=
"
step
"
,
label
=
"
Before
"
,
ax
=
ax
)[
0
]
Y
.
plot
.
hist
(
bins
=
bin_edges
,
density
=
True
,
histtype
=
"
step
"
,
label
=
"
Before
"
,
ax
=
ax
)[
0
]
Y_extreme
.
plot
.
hist
(
bins
=
bin_edges
,
density
=
True
,
histtype
=
"
step
"
,
label
=
"
After
"
,
ax
=
ax
)[
0
]
Y_extreme
.
plot
.
hist
(
bins
=
bin_edges
,
density
=
True
,
histtype
=
"
step
"
,
label
=
"
After
"
,
ax
=
ax
)[
0
]
ax
.
set_title
(
f
"
Density Histogram before-after oversampling
"
)
ax
.
set_title
(
f
"
Density Histogram before-after oversampling
"
)
ax
.
legend
()
ax
.
legend
()
def
_plot_oversampling_rates
(
self
,
oversampling_rates
,
real_oversampling
):
@TimeTrackingWrapper
class
PlotOversamplingRates
(
AbstractPlotClass
):
def
__init__
(
self
,
Y
,
Y_extreme
,
bin_edges
,
oversampling_rates
,
Y_hist
,
Y_extreme_hist
,
plot_folder
:
str
=
"
.
"
,
plot_name
=
"
oversampling_rates
"
):
super
().
__init__
(
plot_folder
,
plot_name
)
self
.
_plot
(
Y
,
Y_extreme
,
bin_edges
,
oversampling_rates
,
Y_hist
,
Y_extreme_hist
)
self
.
_save
()
def
_plot
(
self
,
Y
,
Y_extreme
,
bin_edges
,
oversampling_rates
,
Y_hist
,
Y_extreme_hist
):
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
real_oversampling
=
Y_extreme_hist
[
0
]
/
Y_hist
[
0
]
ax
.
plot
(
range
(
len
(
real_oversampling
)),
oversampling_rates
,
label
=
"
Desired oversampling_rates
"
)
ax
.
plot
(
range
(
len
(
real_oversampling
)),
oversampling_rates
,
label
=
"
Desired oversampling_rates
"
)
ax
.
plot
(
range
(
len
(
real_oversampling
)),
real_oversampling
,
label
=
"
Actual Oversampling Rates
"
)
ax
.
plot
(
range
(
len
(
real_oversampling
)),
real_oversampling
,
label
=
"
Actual Oversampling Rates
"
)
ax
.
set_title
(
f
"
Oversampling rates
"
)
ax
.
set_title
(
f
"
Oversampling rates
"
)
ax
.
legend
()
ax
.
legend
()
def
_plot_oversampling_rates_deviation
(
self
,
oversampling_rates
,
real_oversampling
):
@TimeTrackingWrapper
class
PlotOversamplingRatesDeviation
(
AbstractPlotClass
):
def
__init__
(
self
,
Y
,
Y_extreme
,
bin_edges
,
oversampling_rates
,
Y_hist
,
Y_extreme_hist
,
plot_folder
:
str
=
"
.
"
,
plot_name
=
"
oversampling_rates_deviation
"
):
super
().
__init__
(
plot_folder
,
plot_name
)
self
.
_plot
(
Y
,
Y_extreme
,
bin_edges
,
oversampling_rates
,
Y_hist
,
Y_extreme_hist
)
self
.
_save
()
def
_plot
(
self
,
Y
,
Y_extreme
,
bin_edges
,
oversampling_rates
,
Y_hist
,
Y_extreme_hist
):
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
real_oversampling
=
Y_extreme_hist
[
0
]
/
Y_hist
[
0
]
ax
.
plot
(
range
(
len
(
real_oversampling
)),
real_oversampling
/
oversampling_rates
,
ax
.
plot
(
range
(
len
(
real_oversampling
)),
real_oversampling
/
oversampling_rates
,
label
=
"
Actual/Desired Rate
"
)
label
=
"
Actual/Desired Rate
"
)
ax
.
set_title
(
f
"
Deviation from desired oversampling rates
"
)
ax
.
set_title
(
f
"
Deviation from desired oversampling rates
"
)
...
...
This diff is collapsed.
Click to expand it.
mlair/run_modules/post_processing.py
+
2
−
10
View file @
8bf45b43
...
@@ -22,8 +22,7 @@ from mlair.model_modules import AbstractModelClass
...
@@ -22,8 +22,7 @@ from mlair.model_modules import AbstractModelClass
from
mlair.plotting.postprocessing_plotting
import
PlotMonthlySummary
,
PlotClimatologicalSkillScore
,
\
from
mlair.plotting.postprocessing_plotting
import
PlotMonthlySummary
,
PlotClimatologicalSkillScore
,
\
PlotCompetitiveSkillScore
,
PlotTimeSeries
,
PlotBootstrapSkillScore
,
PlotConditionalQuantiles
,
PlotSeparationOfScales
PlotCompetitiveSkillScore
,
PlotTimeSeries
,
PlotBootstrapSkillScore
,
PlotConditionalQuantiles
,
PlotSeparationOfScales
from
mlair.plotting.data_insight_plotting
import
PlotStationMap
,
PlotAvailability
,
PlotAvailabilityHistogram
,
\
from
mlair.plotting.data_insight_plotting
import
PlotStationMap
,
PlotAvailability
,
PlotAvailabilityHistogram
,
\
PlotPeriodogram
,
PlotDataHistogram
,
PlotOversamplingHistogram
,
PlotOversamplingDensityHistogram
,
\
PlotPeriodogram
,
PlotDataHistogram
,
PlotOversampling
PlotOversamplingRates
,
PlotOversamplingRatesDeviation
from
mlair.run_modules.run_environment
import
RunEnvironment
from
mlair.run_modules.run_environment
import
RunEnvironment
...
@@ -313,14 +312,7 @@ class PostProcessing(RunEnvironment):
...
@@ -313,14 +312,7 @@ class PostProcessing(RunEnvironment):
oversampling_rates
=
self
.
data_store
.
get
(
'
oversampling_rates_capped
'
,
'
train
'
)
oversampling_rates
=
self
.
data_store
.
get
(
'
oversampling_rates_capped
'
,
'
train
'
)
Y
=
self
.
data_store
.
get
(
'
Oversampling_Y
'
)
Y
=
self
.
data_store
.
get
(
'
Oversampling_Y
'
)
Y_extreme
=
self
.
data_store
.
get
(
'
Oversampling_Y_extreme
'
)
Y_extreme
=
self
.
data_store
.
get
(
'
Oversampling_Y_extreme
'
)
Y_hist
=
Y
.
plot
.
hist
(
bins
=
bin_edges
,
histtype
=
"
step
"
)
PlotOversampling
(
Y
,
Y_extreme
,
bin_edges
,
oversampling_rates
,
plot_folder
=
self
.
plot_path
)
Y_extreme_hist
=
Y_extreme
.
plot
.
hist
(
bins
=
bin_edges
,
histtype
=
"
step
"
)
PlotOversamplingHistogram
(
Y
,
Y_extreme
,
bin_edges
,
plot_folder
=
self
.
plot_path
)
PlotOversamplingDensityHistogram
(
Y
,
Y_extreme
,
bin_edges
,
plot_folder
=
self
.
plot_path
)
PlotOversamplingRates
(
Y
,
Y_extreme
,
bin_edges
,
oversampling_rates
,
Y_hist
,
Y_extreme_hist
,
plot_folder
=
self
.
plot_path
)
PlotOversamplingRatesDeviation
(
Y
,
Y_extreme
,
bin_edges
,
oversampling_rates
,
Y_hist
,
Y_extreme_hist
,
plot_folder
=
self
.
plot_path
)
except
Exception
as
e
:
except
Exception
as
e
:
logging
.
error
(
f
"
Could not create plot OversamplingPlots due to the following error:
{
e
}
"
)
logging
.
error
(
f
"
Could not create plot OversamplingPlots due to the following error:
{
e
}
"
)
...
...
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