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
9d83f5eb
Commit
9d83f5eb
authored
6 years ago
by
Nikolai
Browse files
Options
Downloads
Patches
Plain Diff
trying to consistently treat masking
parent
c055faa6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plotting.py
+9
-2
9 additions, 2 deletions
plotting.py
scripts/plot_NN_2D.py
+17
-7
17 additions, 7 deletions
scripts/plot_NN_2D.py
with
26 additions
and
9 deletions
plotting.py
+
9
−
2
View file @
9d83f5eb
...
...
@@ -32,8 +32,15 @@ def save_show(plt, fig, filename):
return
None
def
get_mean_event
(
x
,
y
,
class_label
):
return
[
np
.
mean
(
x
[
y
==
class_label
][:,
var_index
])
for
var_index
in
range
(
x
.
shape
[
1
])]
def
get_mean_event
(
x
,
y
,
class_label
,
mask_value
=
None
):
means
=
[]
for
var_index
in
range
(
x
.
shape
[
1
]):
if
mask_value
is
not
None
:
masked_values
=
np
.
where
(
x
[:,
var_index
]
==
mask_value
)[
0
]
x
=
x
[
masked_values
]
y
=
y
[
masked_values
]
means
.
append
(
np
.
mean
(
x
[
y
==
class_label
][:,
var_index
]))
return
means
def
plot_NN_vs_var_1D
(
plotname
,
means
,
scorefun
,
var_index
,
var_range
,
var_label
=
None
):
...
...
This diff is collapsed.
Click to expand it.
scripts/plot_NN_2D.py
+
17
−
7
View file @
9d83f5eb
...
...
@@ -73,13 +73,21 @@ else:
varx_label
=
args
.
varx
vary_label
=
args
.
vary
# percentilesx = np.percentile(c.x_test[:,varx_index], [1,99])
# percentilesy = np.percentile(c.x_test[:,vary_index], [1,99])
total_weights
=
c
.
w_test
*
np
.
array
(
c
.
class_weight
)[
c
.
y_test
.
astype
(
int
)]
percentilesx
=
weighted_quantile
(
c
.
x_test
[:,
varx_index
],
[
0.1
,
0.99
],
sample_weight
=
total_weights
)
percentilesy
=
weighted_quantile
(
c
.
x_test
[:,
vary_index
],
[
0.1
,
0.99
],
sample_weight
=
total_weights
)
try
:
mask_value
=
c
.
mask_value
except
NameError
:
mask_value
=
None
varx_test
=
c
.
x_test
[:,
varx_index
]
vary_test
=
c
.
x_test
[:,
vary_index
]
x_not_masked
=
np
.
where
(
varx_test
!=
mask_value
)[
0
]
y_not_masked
=
np
.
where
(
vary_test
!=
mask_value
)[
0
]
percentilesx
=
weighted_quantile
(
varx_test
[
x_not_masked
],
[
0.1
,
0.99
],
sample_weight
=
total_weights
[
x_not_masked
])
percentilesy
=
weighted_quantile
(
vary_test
[
y_not_masked
],
[
0.1
,
0.99
],
sample_weight
=
total_weights
[
y_not_masked
])
if
args
.
xrange
is
not
None
:
if
len
(
args
.
xrange
)
<
3
:
...
...
@@ -100,9 +108,11 @@ else:
if
args
.
mode
.
startswith
(
"
mean
"
):
if
args
.
mode
==
"
mean_sig
"
:
means
=
get_mean_event
(
c
.
x_test
,
c
.
y_test
,
1
)
means
=
get_mean_event
(
c
.
x_test
,
c
.
y_test
,
1
,
mask_value
=
mask_value
)
elif
args
.
mode
==
"
mean_bkg
"
:
means
=
get_mean_event
(
c
.
x_test
,
c
.
y_test
,
0
)
means
=
get_mean_event
(
c
.
x_test
,
c
.
y_test
,
0
,
mask_value
=
mask_value
)
print
(
means
)
if
hasattr
(
c
,
"
get_input_list
"
):
input_transform
=
c
.
get_input_list
...
...
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