-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.py
150 lines (122 loc) · 4.25 KB
/
plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import logging, pickle
from utils.utils import get_args
from utils.config import process_config
from utils.handler import Handler
from data_loader.example_data_loader import DatasetGenerator
from plotters.kinematics import Kinematics
from plotters.history import History
from plotters.plot_all import PlotAll
from plotters.performance import Performance
from plotters.compare import Compare
def plot():
try:
args = get_args()
config = process_config(args.config)
logging.basicConfig(
# filename='logs.log',
level=args.loglevel.upper(),
format='%(asctime)s:%(levelname)s:%(message)s',
encoding='utf-8',
handlers=[
logging.FileHandler('logs.log'),
logging.StreamHandler(),
],
force=True, # this is important to overwrite the previously set default logging level
)
# matplotlib logger is being too verbose, need to turn it off
logging.getLogger('matplotlib').setLevel(logging.ERROR)
# numeric_level = getattr(logging, args.loglevel.upper(), None)
# logger = logging.getLogger('no_spam')
# logger.setLevel(numeric_level)
logging.info('Logging level set to: {}'.format(args.loglevel.upper()))
logging.debug('args: {}'.format(args))
logging.debug('args.config: {}'.format(args.config))
logging.debug('config: {}'.format(config))
except:
logging.critical("Missing or invalid arguments")
exit(0)
# df, _ = DatasetGenerator(config, mode='pd', normed=False)()
handler = Handler(config)
dataloader = DatasetGenerator(config)
raw_data = handler.load('raw_data')
normalized_data = handler.load('normalized_data')
model = handler.load('model')
train_history = handler.load('history')
test_data = handler.load('test_data') # loads in pandas dataframe
train_data = handler.load('train_data')
normalization_factors = handler.load('normalization_factors')
logging.debug(f'type(model): {type(model)}')
logging.debug(f'Normalization factors: {normalization_factors}')
logging.debug(f'test_data[0].describe(): {test_data[0].describe()}')
logging.debug(f'test_data[1].describe(): {test_data[1].describe()}')
kinematics = Kinematics(config)
history = History(config)
plot_all = PlotAll(config)
performance = Performance(config, normalization_factors)
compare = Compare(config)
# kinematics.plot(raw_data, title='Normalized', yscale='log')
history.plot(train_history, title='Training History')
plot_all.plot(raw_data, yscale='log')
plot_all.plot(normalized_data, pretitle='Normalized', yscale='log')
performance.plot(
model,
test_data,
# avoid_plotting=['target_vs_predicted', 'total_residuals', 'binned_residuals', 'feature_importance', 'feature_vs_residuals'],
comparison_ylim=(0,100)
)
with open(config.base_path + '/raw_data_Zee.pkl', 'rb') as f:
raw_data_Zee = pickle.load(f)
with open(config.base_path + '/raw_data_signal.pkl', 'rb') as f:
raw_data_signal = pickle.load(f)
raw_data_Zee = raw_data_Zee.drop(columns=[
'el1_pt',
'el2_pt',
'el1_E',
'el2_E',
# 'el1_eta',
# 'el2_eta',
'el1_phi',
'el2_phi',
'ph1_pt',
'ph2_pt',
'ph1_E',
'ph2_E',
# 'ph1_eta',
# 'ph2_eta',
'ph1_phi',
'ph2_phi',
'PassTrig_g35_loose_g25_loose',
'PassTrig_g35_medium_g25_medium',
'TV_x',
'TV_y',
],
errors='ignore',
)
raw_data_signal = raw_data_signal.drop(columns=[
'el1_pt',
'el2_pt',
'el1_E',
'el2_E',
# 'el1_eta',
# 'el2_eta',
'el1_phi',
'el2_phi',
'ph1_pt',
'ph2_pt',
'ph1_E',
'ph2_E',
# 'ph1_eta',
# 'ph2_eta',
'ph1_phi',
'ph2_phi',
'PassTrig_g35_loose_g25_loose',
'PassTrig_g35_medium_g25_medium',
'TV_x',
'TV_y',
],
errors='ignore',
)
# compare.plot(raw_data_Zee, raw_data_signal, names=['Zee', 'Signal'], yscale='log')
if __name__ == '__main__':
# only if ran as a script
plot()