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
Commits
cc9e0663
Commit
cc9e0663
authored
6 years ago
by
Nikolai.Hartmann
Browse files
Options
Downloads
Patches
Plain Diff
Normalise training and test sample correctly for significance scan
parent
01681528
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
toolkit.py
+10
-5
10 additions, 5 deletions
toolkit.py
with
10 additions
and
5 deletions
toolkit.py
+
10
−
5
View file @
cc9e0663
...
@@ -921,15 +921,18 @@ class ClassificationProject(object):
...
@@ -921,15 +921,18 @@ class ClassificationProject(object):
significances_train
=
[]
significances_train
=
[]
significances_test
=
[]
significances_test
=
[]
for
hist_sig
,
hist_bkg
,
rel_errors_sig
,
rel_errors_bkg
,
significances
in
[
for
hist_sig
,
hist_bkg
,
rel_errors_sig
,
rel_errors_bkg
,
significances
,
w
,
y
in
[
(
hist_sig_train
,
hist_bkg_train
,
rel_errors_bkg_train
,
rel_errors_sig_train
,
significances_train
),
(
hist_sig_train
,
hist_bkg_train
,
rel_errors_bkg_train
,
rel_errors_sig_train
,
significances_train
,
self
.
w_train
,
self
.
y_train
),
(
hist_sig_test
,
hist_bkg_test
,
rel_errors_bkg_test
,
rel_errors_sig_test
,
significances_test
),
(
hist_sig_test
,
hist_bkg_test
,
rel_errors_bkg_test
,
rel_errors_sig_test
,
significances_test
,
self
.
w_test
,
self
.
y_test
),
]:
]:
# factor to rescale due to using only a fraction of events (training and test samples)
normfactor_sig
=
(
np
.
sum
(
self
.
w_train
[
self
.
y_train
==
1
])
+
np
.
sum
(
self
.
w_test
[
self
.
y_test
==
1
]))
/
np
.
sum
(
w
[
y
==
1
])
normfactor_bkg
=
(
np
.
sum
(
self
.
w_train
[
self
.
y_train
==
0
])
+
np
.
sum
(
self
.
w_test
[
self
.
y_test
==
0
]))
/
np
.
sum
(
w
[
y
==
0
])
# first set nan values to 0 and multiply by lumi
# first set nan values to 0 and multiply by lumi
for
arr
in
hist_sig
,
hist_bkg
,
rel_errors_bkg
:
for
arr
in
hist_sig
,
hist_bkg
,
rel_errors_bkg
:
arr
[
np
.
isnan
(
arr
)]
=
0
arr
[
np
.
isnan
(
arr
)]
=
0
hist_sig
*=
lumifactor
hist_sig
*=
lumifactor
*
normfactor_sig
hist_bkg
*=
lumifactor
hist_bkg
*=
lumifactor
*
normfactor_bkg
for
i
in
range
(
len
(
hist_sig
)):
for
i
in
range
(
len
(
hist_sig
)):
s
=
sum
(
hist_sig
[
i
:])
s
=
sum
(
hist_sig
[
i
:])
b
=
sum
(
hist_bkg
[
i
:])
b
=
sum
(
hist_bkg
[
i
:])
...
@@ -941,6 +944,8 @@ class ClassificationProject(object):
...
@@ -941,6 +944,8 @@ class ClassificationProject(object):
z
=
0
z
=
0
else
:
else
:
z
=
significanceFunction
(
s
,
b
,
db
)
z
=
significanceFunction
(
s
,
b
,
db
)
if
z
==
float
(
'
inf
'
):
z
=
0
logger
.
debug
(
"
s, b, db, z = {}, {}, {}, {}
"
.
format
(
s
,
b
,
db
,
z
))
logger
.
debug
(
"
s, b, db, z = {}, {}, {}, {}
"
.
format
(
s
,
b
,
db
,
z
))
significances
.
append
(
z
)
significances
.
append
(
z
)
...
...
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