Skip to content
Snippets Groups Projects
Commit 062df5b5 authored by Nikolai.Hartmann's avatar Nikolai.Hartmann
Browse files

Merge remote-tracking branch 'origin/master'

parents 2e9b6f67 cfa87567
No related branches found
No related tags found
No related merge requests found
from .toolkit import ClassificationProject
from .compare import overlay_ROC, overlay_loss
from .add_friend import add_friend
from .toolkit import *
from .compare import *
from .add_friend import *
#!/usr/bin/env python
__all__ = ["ClassificationProject"]
from sys import version_info
if version_info[0] > 2:
......@@ -69,6 +71,7 @@ def byteify(input):
if version_info[0] > 2:
byteify = lambda input : input
class ClassificationProject(object):
"""Simple framework to load data from ROOT TTrees and train Keras
......@@ -1160,6 +1163,22 @@ class ClassificationProject(object):
# self.plot_significance()
def to_DataFrame(self):
df = pd.DataFrame(np.concatenate([self.x_train, self.x_test]), columns=self.fields)
df["weight"] = np.concatenate([self.w_train, self.w_test])
df["labels"] = pd.Categorical.from_codes(
np.concatenate([self.y_train, self.y_test]),
categories=["background", "signal"]
)
for identifier in self.identifiers:
df[identifier] = np.concatenate([self.s_eventlist_train[identifier],
self.b_eventlist_train[identifier],
-1*np.ones(len(self.x_test), dtype="i8")])
df["is_train"] = np.concatenate([np.ones(len(self.x_train), dtype=np.bool),
np.zeros(len(self.x_test), dtype=np.bool)])
return df
def create_getter(dataset_name):
def getx(self):
if getattr(self, "_"+dataset_name) is None:
......@@ -1178,6 +1197,17 @@ for dataset_name in ClassificationProject.dataset_names:
create_setter(dataset_name)))
# class ClassificationProjectDataFrame(ClassificationProject):
# """
# A little hack to initialize a ClassificationProject from a pandas DataFrame instead of ROOT TTrees
# """
# def __init__(self,
# **kwargs):
# pass
if __name__ == "__main__":
logging.basicConfig()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment