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
Eric.Schanet
KerasROOTClassification
Commits
4370211b
Commit
4370211b
authored
6 years ago
by
Nikolai
Browse files
Options
Downloads
Patches
Plain Diff
trying to implement 2D ratio hist
parent
dc93ef02
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plotting.py
+29
-0
29 additions, 0 deletions
plotting.py
scripts/plot_NN_2D.py
+27
-2
27 additions, 2 deletions
scripts/plot_NN_2D.py
with
56 additions
and
2 deletions
plotting.py
+
29
−
0
View file @
4370211b
...
...
@@ -250,6 +250,35 @@ def plot_hist_2D_events(plotname, valsx, valsy, nbinsx, xmin, xmax, nbinsy, ymin
plot_hist_2D
(
plotname
,
xedges
,
yedges
,
hist
,
varx_label
,
vary_label
,
log
)
def
plot_hist_2D_events_ratio
(
plotname
,
valsx1
,
valsy1
,
valsx2
,
valsy2
,
nbinsx
,
xmin
,
xmax
,
nbinsy
,
ymin
,
ymax
,
weights1
=
None
,
weights2
=
None
,
varx_label
=
None
,
vary_label
=
None
,
log
=
False
):
xedges
=
np
.
linspace
(
xmin
,
xmax
,
nbinsx
)
yedges
=
np
.
linspace
(
ymin
,
ymax
,
nbinsy
)
hist1
,
xedges
,
yedges
=
np
.
histogram2d
(
valsx1
,
valsy1
,
bins
=
(
xedges
,
yedges
),
weights
=
weights1
)
hist2
,
xedges
,
yedges
=
np
.
histogram2d
(
valsx2
,
valsy2
,
bins
=
(
xedges
,
yedges
),
weights
=
weights2
)
hist1
=
hist1
.
T
hist2
=
hist2
.
T
hist1
/=
hist1
.
sum
()
hist2
/=
hist2
.
sum
()
hist2
[
hist2
==
0
]
=
np
.
nan
hist
=
hist1
/
hist2
print
(
hist
)
plot_hist_2D
(
plotname
,
xedges
,
yedges
,
hist
,
varx_label
,
vary_label
,
log
)
def
plot_cond_avg_actmax_2D
(
plotname
,
model
,
layer
,
neuron
,
ranges
,
varx_index
,
vary_index
,
nbinsx
,
xmin
,
xmax
,
nbinsy
,
ymin
,
ymax
,
...
...
This diff is collapsed.
Click to expand it.
scripts/plot_NN_2D.py
+
27
−
2
View file @
4370211b
...
...
@@ -13,6 +13,7 @@ from KerasROOTClassification.plotting import (
plot_NN_vs_var_2D
,
plot_profile_2D
,
plot_hist_2D_events
,
plot_hist_2D_events_ratio
,
plot_cond_avg_actmax_2D
)
from
KerasROOTClassification.utils
import
get_single_neuron_function
,
get_max_activation_events
...
...
@@ -23,7 +24,7 @@ parser.add_argument("output_filename")
parser
.
add_argument
(
"
varx
"
)
parser
.
add_argument
(
"
vary
"
)
parser
.
add_argument
(
"
-m
"
,
"
--mode
"
,
choices
=
[
"
mean_sig
"
,
"
mean_bkg
"
,
"
profile_sig
"
,
"
profile_bkg
"
,
"
hist_sig
"
,
"
hist_bkg
"
,
"
hist_actmax
"
,
"
cond_actmax
"
],
choices
=
[
"
mean_sig
"
,
"
mean_bkg
"
,
"
profile_sig
"
,
"
profile_bkg
"
,
"
hist_sig
"
,
"
hist_bkg
"
,
"
hist_ratio
"
,
"
hist_actmax
"
,
"
cond_actmax
"
],
default
=
"
mean_sig
"
)
parser
.
add_argument
(
"
-l
"
,
"
--layer
"
,
type
=
int
,
help
=
"
Layer index (takes last layer by default)
"
)
parser
.
add_argument
(
"
-n
"
,
"
--neuron
"
,
type
=
int
,
default
=
0
,
help
=
"
Neuron index (takes first neuron by default)
"
)
...
...
@@ -134,7 +135,7 @@ elif args.mode.startswith("profile"):
**
opt_kwargs
)
elif
args
.
mode
.
startswith
(
"
hist
"
):
elif
args
.
mode
.
startswith
(
"
hist
"
)
and
not
args
.
mode
==
"
hist_ratio
"
:
if
not
args
.
mode
==
"
hist_actmax
"
:
if
args
.
mode
==
"
hist_sig
"
:
...
...
@@ -171,6 +172,30 @@ elif args.mode.startswith("hist"):
log
=
args
.
log
,
)
elif
args
.
mode
==
"
hist_ratio
"
:
valsx1
=
c
.
x_test
[
c
.
y_test
==
1
][:,
varx_index
]
valsx2
=
c
.
x_test
[
c
.
y_test
==
0
][:,
varx_index
]
if
not
plot_vs_activation
:
valsy1
=
c
.
x_test
[
c
.
y_test
==
1
][:,
vary_index
]
valsy2
=
c
.
x_test
[
c
.
y_test
==
0
][:,
vary_index
]
else
:
valsy1
=
c
.
scores_test
[
c
.
y_test
==
1
].
reshape
(
-
1
)
valsy2
=
c
.
scores_test
[
c
.
y_test
==
0
].
reshape
(
-
1
)
weights1
=
c
.
w_test
[
c
.
y_test
==
1
]
weights2
=
c
.
w_test
[
c
.
y_test
==
0
]
plot_hist_2D_events_ratio
(
args
.
output_filename
,
valsx1
,
valsy1
,
valsx2
,
valsy2
,
xmin
=
varx_range
[
0
],
xmax
=
varx_range
[
1
],
nbinsx
=
varx_range
[
2
],
ymin
=
vary_range
[
0
],
ymax
=
vary_range
[
1
],
nbinsy
=
vary_range
[
2
],
weights1
=
weights1
,
weights2
=
weights2
,
varx_label
=
varx_label
,
vary_label
=
vary_label
,
log
=
args
.
log
,
)
elif
args
.
mode
.
startswith
(
"
cond_actmax
"
):
x_test_scaled
=
c
.
scaler
.
transform
(
c
.
x_test
)
...
...
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