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
1b054380
Commit
1b054380
authored
6 years ago
by
Nikolai.Hartmann
Browse files
Options
Downloads
Patches
Plain Diff
hist mode for plot_single_neuron
parent
903910f2
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
+4
-2
4 additions, 2 deletions
plotting.py
scripts/plot_single_neuron.py
+31
-7
31 additions, 7 deletions
scripts/plot_single_neuron.py
with
35 additions
and
9 deletions
plotting.py
+
4
−
2
View file @
1b054380
...
...
@@ -236,12 +236,14 @@ def plot_hist_2D(plotname, xedges, yedges, hist, varx_label=None, vary_label=Non
plt
.
close
(
fig
)
def
plot_hist_2D_events
(
plotname
,
valsx
,
valsy
,
nbinsx
,
xmin
,
xmax
,
nbinsy
,
ymin
,
ymax
,
varx_label
=
None
,
vary_label
=
None
,
log
=
False
):
def
plot_hist_2D_events
(
plotname
,
valsx
,
valsy
,
nbinsx
,
xmin
,
xmax
,
nbinsy
,
ymin
,
ymax
,
weights
=
None
,
varx_label
=
None
,
vary_label
=
None
,
log
=
False
):
xedges
=
np
.
linspace
(
xmin
,
xmax
,
nbinsx
)
yedges
=
np
.
linspace
(
ymin
,
ymax
,
nbinsy
)
hist
,
xedges
,
yedges
=
np
.
histogram2d
(
valsx
,
valsy
,
bins
=
(
xedges
,
yedges
))
hist
,
xedges
,
yedges
=
np
.
histogram2d
(
valsx
,
valsy
,
bins
=
(
xedges
,
yedges
)
,
weights
=
weights
)
hist
=
hist
.
T
...
...
This diff is collapsed.
Click to expand it.
scripts/plot_single_neuron.py
+
31
−
7
View file @
1b054380
...
...
@@ -9,7 +9,8 @@ from KerasROOTClassification import ClassificationProject
from
KerasROOTClassification.plotting
import
(
get_mean_event
,
plot_NN_vs_var_2D
,
plot_profile_2D
plot_profile_2D
,
plot_hist_2D_events
)
from
KerasROOTClassification.tfhelpers
import
get_single_neuron_function
...
...
@@ -18,7 +19,9 @@ parser.add_argument("project_dir")
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
"
],
default
=
"
mean_sig
"
)
parser
.
add_argument
(
"
-m
"
,
"
--mode
"
,
choices
=
[
"
mean_sig
"
,
"
mean_bkg
"
,
"
profile_sig
"
,
"
profile_bkg
"
,
"
hist_sig
"
,
"
hist_bkg
"
],
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)
"
)
parser
.
add_argument
(
"
--log
"
,
action
=
"
store_true
"
,
help
=
"
Plot in color in log scale
"
)
...
...
@@ -41,10 +44,11 @@ if layer is None:
varx_index
=
c
.
branches
.
index
(
args
.
varx
)
vary_index
=
c
.
branches
.
index
(
args
.
vary
)
x_test
=
c
.
x_test
varx_label
=
args
.
varx
vary_label
=
args
.
vary
percentilesx
=
np
.
percentile
(
x_test
[:,
varx_index
],
[
1
,
99
])
percentilesy
=
np
.
percentile
(
x_test
[:,
vary_index
],
[
1
,
99
])
percentilesx
=
np
.
percentile
(
c
.
x_test
[:,
varx_index
],
[
1
,
99
])
percentilesy
=
np
.
percentile
(
c
.
x_test
[:,
vary_index
],
[
1
,
99
])
if
args
.
xrange
is
not
None
:
if
len
(
args
.
xrange
)
<
3
:
...
...
@@ -75,7 +79,7 @@ if args.mode.startswith("mean"):
scorefun
=
get_single_neuron_function
(
c
.
model
,
layer
,
neuron
,
scaler
=
c
.
scaler
),
xmin
=
varx_range
[
0
],
xmax
=
varx_range
[
1
],
nbinsx
=
varx_range
[
2
],
ymin
=
vary_range
[
0
],
ymax
=
vary_range
[
1
],
nbinsy
=
vary_range
[
2
],
varx_label
=
args
.
varx
,
vary_label
=
args
.
vary
,
varx_label
=
varx_label
,
vary_label
=
vary_label
,
logscale
=
args
.
log
,
only_pixels
=
(
not
args
.
contour
)
)
...
...
@@ -106,6 +110,26 @@ elif args.mode.startswith("profile"):
xmin
=
varx_range
[
0
],
xmax
=
varx_range
[
1
],
nbinsx
=
varx_range
[
2
],
ymin
=
vary_range
[
0
],
ymax
=
vary_range
[
1
],
nbinsy
=
vary_range
[
2
],
metric
=
metric_dict
[
args
.
profile_metric
],
varx_label
=
"
met [GeV]
"
,
vary_label
=
"
mt [GeV]
"
,
varx_label
=
varx_label
,
vary_label
=
vary_label
,
**
opt_kwargs
)
elif
args
.
mode
.
startswith
(
"
hist
"
):
if
args
.
mode
==
"
hist_sig
"
:
class_index
=
1
else
:
class_index
=
0
valsx
=
c
.
x_test
[
c
.
y_test
==
class_index
][:,
varx_index
]
valsy
=
c
.
x_test
[
c
.
y_test
==
class_index
][:,
vary_index
]
weights
=
c
.
w_test
[
c
.
y_test
==
class_index
]
plot_hist_2D_events
(
args
.
output_filename
,
valsx
,
valsy
,
xmin
=
varx_range
[
0
],
xmax
=
varx_range
[
1
],
nbinsx
=
varx_range
[
2
],
ymin
=
vary_range
[
0
],
ymax
=
vary_range
[
1
],
nbinsy
=
vary_range
[
2
],
weights
=
weights
,
varx_label
=
varx_label
,
vary_label
=
vary_label
,
)
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