Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
KerasROOTClassification
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
Nikolai.Hartmann
KerasROOTClassification
Compare revisions
0a718e65f383458c7b690520b30d5d80c3fb6694 to master
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
Nikolai.Hartmann/KerasROOTClassification
Select target project
No results found
master
Select Git revision
Swap
Target
Eric.Schanet/KerasROOTClassification
Select target project
Eric.Schanet/KerasROOTClassification
Nikolai.Hartmann/KerasROOTClassification
2 results
0a718e65f383458c7b690520b30d5d80c3fb6694
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
fix WeightedRobustScaler
· 79807735
Nikolai Hartmann
authored
6 years ago
79807735
fix plot_input for usage with training batches
· 367e8290
Nikolai.Hartmann
authored
6 years ago
367e8290
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
toolkit.py
+5
-0
5 additions, 0 deletions
toolkit.py
utils.py
+18
-6
18 additions, 6 deletions
utils.py
with
23 additions
and
6 deletions
toolkit.py
View file @
367e8290
...
@@ -651,6 +651,7 @@ class ClassificationProject(object):
...
@@ -651,6 +651,7 @@ class ClassificationProject(object):
elif
self
.
scaler_type
==
"
WeightedRobustScaler
"
:
elif
self
.
scaler_type
==
"
WeightedRobustScaler
"
:
self
.
_scaler
=
WeightedRobustScaler
()
self
.
_scaler
=
WeightedRobustScaler
()
scaler_fit_kwargs
[
"
weights
"
]
=
self
.
w_train_tot
scaler_fit_kwargs
[
"
weights
"
]
=
self
.
w_train_tot
scaler_fit_kwargs
[
"
mask_value
"
]
=
self
.
mask_value
else
:
else
:
raise
ValueError
(
"
Scaler type {} unknown
"
.
format
(
self
.
scaler_type
))
raise
ValueError
(
"
Scaler type {} unknown
"
.
format
(
self
.
scaler_type
))
logger
.
info
(
"
Fitting {} to training data
"
.
format
(
self
.
scaler_type
))
logger
.
info
(
"
Fitting {} to training data
"
.
format
(
self
.
scaler_type
))
...
@@ -1334,6 +1335,10 @@ class ClassificationProject(object):
...
@@ -1334,6 +1335,10 @@ class ClassificationProject(object):
break
break
if
self
.
target_fields
:
if
self
.
target_fields
:
y
=
y
[
0
]
y
=
y
[
0
]
try
:
x
=
self
.
get_input_flat
(
x
)
except
NameError
:
pass
bkg_batch
=
x
[:,
var_index
][
y
==
0
]
bkg_batch
=
x
[:,
var_index
][
y
==
0
]
sig_batch
=
x
[:,
var_index
][
y
==
1
]
sig_batch
=
x
[:,
var_index
][
y
==
1
]
bkg_weights_batch
=
w
[
y
==
0
]
bkg_weights_batch
=
w
[
y
==
0
]
...
...
This diff is collapsed.
Click to expand it.
utils.py
View file @
367e8290
...
@@ -197,14 +197,26 @@ def weighted_quantile(values, quantiles, sample_weight=None, values_sorted=False
...
@@ -197,14 +197,26 @@ def weighted_quantile(values, quantiles, sample_weight=None, values_sorted=False
class
WeightedRobustScaler
(
RobustScaler
):
class
WeightedRobustScaler
(
RobustScaler
):
def
fit
(
self
,
X
,
y
=
None
,
weights
=
None
):
def
fit
(
self
,
X
,
y
=
None
,
weights
=
None
,
mask_value
=
None
):
if
not
np
.
isnan
(
X
).
any
():
if
not
np
.
isnan
(
X
).
any
()
and
mask_value
is
not
None
and
weights
is
None
:
# these checks don't work for nan values
# these checks don't work for nan values
super
(
WeightedRobustScaler
,
self
).
fit
(
X
,
y
)
return
super
(
WeightedRobustScaler
,
self
).
fit
(
X
,
y
)
if
weights
is
None
:
return
self
else
:
else
:
wqs
=
np
.
array
([
weighted_quantile
(
X
[:,
i
][
~
np
.
isnan
(
X
[:,
i
])],
[
0.25
,
0.5
,
0.75
],
sample_weight
=
weights
)
for
i
in
range
(
X
.
shape
[
1
])])
if
weights
is
None
:
weights
=
np
.
ones
(
len
(
self
.
X
))
wqs
=
[]
for
i
in
range
(
X
.
shape
[
1
]):
mask
=
~
np
.
isnan
(
X
[:,
i
])
if
mask_value
is
not
None
:
mask
&=
(
X
[:,
i
]
!=
mask_value
)
wqs
.
append
(
weighted_quantile
(
X
[:,
i
][
mask
],
[
0.25
,
0.5
,
0.75
],
sample_weight
=
weights
[
mask
]
)
)
wqs
=
np
.
array
(
wqs
)
self
.
center_
=
wqs
[:,
1
]
self
.
center_
=
wqs
[:,
1
]
self
.
scale_
=
wqs
[:,
2
]
-
wqs
[:,
0
]
self
.
scale_
=
wqs
[:,
2
]
-
wqs
[:,
0
]
self
.
scale_
=
_handle_zeros_in_scale
(
self
.
scale_
,
copy
=
False
)
self
.
scale_
=
_handle_zeros_in_scale
(
self
.
scale_
,
copy
=
False
)
...
...
This diff is collapsed.
Click to expand it.