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
45199b6c
Commit
45199b6c
authored
3 years ago
by
v.gramlich1
Browse files
Options
Downloads
Patches
Plain Diff
apply_oversampling calculates the desired oversampling_rates
parent
74e6e53c
No related branches found
Branches containing commit
No related tags found
1 merge request
!302
Draft: Resolve "Class-based Oversampling technique"
Pipeline
#70534
passed
3 years ago
Stage: test
Stage: docs
Stage: pages
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mlair/run_modules/pre_processing.py
+30
-0
30 additions, 0 deletions
mlair/run_modules/pre_processing.py
with
30 additions
and
0 deletions
mlair/run_modules/pre_processing.py
+
30
−
0
View file @
45199b6c
...
...
@@ -8,6 +8,8 @@ import os
import
traceback
from
typing
import
Tuple
import
multiprocessing
import
numpy
as
np
import
requests
import
psutil
...
...
@@ -65,9 +67,37 @@ class PreProcessing(RunEnvironment):
raise
ValueError
(
"
Couldn
'
t find any valid data according to given parameters. Abort experiment run.
"
)
self
.
data_store
.
set
(
"
stations
"
,
valid_stations
)
self
.
split_train_val_test
()
self
.
apply_oversampling
()
self
.
report_pre_processing
()
self
.
prepare_competitors
()
def
apply_oversampling
(
self
):
#if Abfrage for oversampling=True/False
bins
=
10
rates_cap
=
20
data
=
self
.
data_store
.
get
(
'
data_collection
'
,
'
train
'
)
histogram
=
np
.
array
(
bins
)
#get min and max of the whole data
min
=
0
max
=
0
for
station
in
data
:
min
=
np
.
minimum
(
np
.
amin
(
station
.
get_Y
(
as_numpy
=
True
)),
min
)
max
=
np
.
maximum
(
np
.
amax
(
station
.
get_Y
(
as_numpy
=
True
)),
max
)
for
station
in
data
:
# erstelle Histogramm mit numpy für jede Station
hist
,
_
=
np
.
histogram
(
station
.
get_Y
(
as_numpy
=
True
),
bins
=
bins
,
range
=
(
min
,
max
))
#histograms.append(hist)
histogram
=
histogram
+
hist
# Addiere alle Histogramme zusammen
#histogram = histograms[0]+histograms[1]+histograms[2]+histograms[3]
#teile durch gesamtanzahl
histogram
=
1
/
np
.
sum
(
histogram
)
*
histogram
#mult mit 1/häufigste Klasse
histogram
=
1
/
np
.
amax
(
histogram
)
*
histogram
#Oversampling 1/Kl
oversampling_rates
=
1
/
histogram
oversampling_rates_capped
=
np
.
minimum
(
oversampling_rates
,
rates_cap
)
def
report_pre_processing
(
self
):
"""
Log some metrics on data and create latex report.
"""
logging
.
debug
(
20
*
'
##
'
)
...
...
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