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
beea1cfe
Commit
beea1cfe
authored
6 years ago
by
Nikolai.Hartmann
Browse files
Options
Downloads
Patches
Plain Diff
Experimental support for initialising from pandas DataFrame (memory intense ...)
parent
0519ccd8
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
+110
-6
110 additions, 6 deletions
toolkit.py
with
110 additions
and
6 deletions
toolkit.py
+
110
−
6
View file @
beea1cfe
#!/usr/bin/env python
#!/usr/bin/env python
__all__
=
[
"
ClassificationProject
"
]
__all__
=
[
"
ClassificationProject
"
,
"
ClassificationProjectDataFrame
"
]
from
sys
import
version_info
from
sys
import
version_info
...
@@ -1171,9 +1171,12 @@ class ClassificationProject(object):
...
@@ -1171,9 +1171,12 @@ class ClassificationProject(object):
categories
=
[
"
background
"
,
"
signal
"
]
categories
=
[
"
background
"
,
"
signal
"
]
)
)
for
identifier
in
self
.
identifiers
:
for
identifier
in
self
.
identifiers
:
df
[
identifier
]
=
np
.
concatenate
([
self
.
s_eventlist_train
[
identifier
],
try
:
self
.
b_eventlist_train
[
identifier
],
df
[
identifier
]
=
np
.
concatenate
([
self
.
s_eventlist_train
[
identifier
],
-
1
*
np
.
ones
(
len
(
self
.
x_test
),
dtype
=
"
i8
"
)])
self
.
b_eventlist_train
[
identifier
],
-
1
*
np
.
ones
(
len
(
self
.
x_test
),
dtype
=
"
i8
"
)])
except
IOError
:
logger
.
warning
(
"
Can
'
t find eventlist - DataFrame won
'
t contain identifiers
"
)
df
[
"
is_train
"
]
=
np
.
concatenate
([
np
.
ones
(
len
(
self
.
x_train
),
dtype
=
np
.
bool
),
df
[
"
is_train
"
]
=
np
.
concatenate
([
np
.
ones
(
len
(
self
.
x_train
),
dtype
=
np
.
bool
),
np
.
zeros
(
len
(
self
.
x_test
),
dtype
=
np
.
bool
)])
np
.
zeros
(
len
(
self
.
x_test
),
dtype
=
np
.
bool
)])
return
df
return
df
...
@@ -1204,15 +1207,116 @@ class ClassificationProjectDataFrame(ClassificationProject):
...
@@ -1204,15 +1207,116 @@ class ClassificationProjectDataFrame(ClassificationProject):
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
name
,
df
,
input_columns
,
input_columns
,
weight_column
=
"
weights
"
,
weight_column
=
"
weights
"
,
label_column
=
"
labels
"
,
label_column
=
"
labels
"
,
signal_label
=
"
signal
"
,
signal_label
=
"
signal
"
,
background_label
=
"
background
"
,
background_label
=
"
background
"
,
split_mode
=
"
split_column
"
,
split_mode
=
"
split_column
"
,
split_colu
r
m
=
"
is_train
"
,
split_colum
n
=
"
is_train
"
,
**
kwargs
):
**
kwargs
):
pass
self
.
df
=
df
self
.
input_columns
=
input_columns
self
.
weight_column
=
weight_column
self
.
label_column
=
label_column
self
.
signal_label
=
signal_label
self
.
background_label
=
background_label
if
split_mode
!=
"
split_column
"
:
raise
NotImplementedError
(
"'
split_column
'
is the only currently supported split mode
"
)
self
.
split_mode
=
split_mode
self
.
split_column
=
split_column
super
(
ClassificationProjectDataFrame
,
self
).
__init__
(
name
,
signal_trees
=
[],
bkg_trees
=
[],
branches
=
[],
weight_expr
=
"
1
"
,
**
kwargs
)
self
.
_x_train
=
None
self
.
_x_test
=
None
self
.
_y_train
=
None
self
.
_y_test
=
None
self
.
_w_train
=
None
self
.
_w_test
=
None
@property
def
x_train
(
self
):
if
self
.
_x_train
is
None
:
self
.
_x_train
=
self
.
df
[
self
.
df
[
self
.
split_column
]][
self
.
input_columns
].
values
return
self
.
_x_train
@x_train.setter
def
x_train
(
self
,
value
):
self
.
_x_train
=
value
@property
def
x_test
(
self
):
if
self
.
_x_test
is
None
:
self
.
_x_test
=
self
.
df
[
~
self
.
df
[
self
.
split_column
]][
self
.
input_columns
].
values
return
self
.
_x_test
@x_test.setter
def
x_test
(
self
,
value
):
self
.
_x_test
=
value
@property
def
y_train
(
self
):
if
self
.
_y_train
is
None
:
self
.
_y_train
=
(
self
.
df
[
self
.
df
[
self
.
split_column
]][
self
.
label_column
]
==
self
.
signal_label
).
values
return
self
.
_y_train
@y_train.setter
def
y_train
(
self
,
value
):
self
.
_y_train
=
value
@property
def
y_test
(
self
):
if
self
.
_y_test
is
None
:
self
.
_y_test
=
(
self
.
df
[
~
self
.
df
[
self
.
split_column
]][
self
.
label_column
]
==
self
.
signal_label
).
values
return
self
.
_y_test
@y_test.setter
def
y_test
(
self
,
value
):
self
.
_y_test
=
value
@property
def
w_train
(
self
):
if
self
.
_w_train
is
None
:
self
.
_w_train
=
self
.
df
[
self
.
df
[
self
.
split_column
]][
self
.
weight_column
].
values
return
self
.
_w_train
@w_train.setter
def
w_train
(
self
,
value
):
self
.
_w_train
=
value
@property
def
w_test
(
self
):
if
self
.
_w_test
is
None
:
self
.
_w_test
=
self
.
df
[
~
self
.
df
[
self
.
split_column
]][
self
.
weight_column
].
values
return
self
.
_w_test
@w_test.setter
def
w_test
(
self
,
value
):
self
.
_w_test
=
value
@property
def
fields
(
self
):
return
self
.
input_columns
def
load
(
self
,
reload
=
False
):
if
reload
:
self
.
data_loaded
=
False
self
.
data_transformed
=
False
self
.
_x_train
=
None
self
.
_x_test
=
None
self
.
_y_train
=
None
self
.
_y_test
=
None
self
.
_w_train
=
None
self
.
_w_test
=
None
if
not
self
.
data_transformed
:
self
.
_transform_data
()
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
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