forked from minxiyang/CS_578_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotRaw.py
65 lines (57 loc) · 2.32 KB
/
plotRaw.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
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
data=pd.read_csv("data/training.csv")
#print(data.head())
#print(data.describe())
#print(data.columns)
for label, content in data.items():
if label!="EventId" and label!="Weight" and label!="Label":
SigWeight=data.loc[(data[label]>-999) & (data['Label']=="s"),["Weight"]]
SigWeight=SigWeight.astype(float)
SigWeight=SigWeight.to_numpy()
SigWeight=SigWeight.reshape(-1,)
SigWeightScaled=SigWeight*100
#print(len(SigWeight))
SigFeature=data.loc[(data[label]>-999) & (data['Label']=="s"),[label]]
SigFeature=SigFeature.astype(float)
SigFeature=SigFeature.to_numpy()
SigFeature=SigFeature.reshape(-1,)
plt.hist(SigFeature,100,weights=SigWeightScaled,label="signal*100",alpha=0.5,facecolor="red")
BkgWeight=data.loc[(data[label]>-999) & (data['Label']=="b"),["Weight"]]
BkgWeight=BkgWeight.astype(float)
BkgWeight=BkgWeight.to_numpy()
BkgWeight=BkgWeight.reshape(-1,)
#print(len(BkgWeight))
BkgFeature=data.loc[(data[label]>-999) & (data['Label']=="b"),[label]]
BkgFeature=BkgFeature.astype(float)
BkgFeature=BkgFeature.to_numpy()
BkgFeature=BkgFeature.reshape(-1,)
#plt.hist([SigFeature,BkgFeature],100,weights=[SigWeightScaled,BkgWeight],label=["signal*100","background"],alpha=0.5)#,facecolor=["red","green"])
plt.hist(BkgFeature,100,weights=BkgWeight,label="background",alpha=0.5,facecolor="green")
plt.legend(loc="upper right")
plt.xlabel(label)
plt.ylabel("distribution")
plt.savefig("plots/plots_raw/"+label+".pdf")
plt.yscale("log")
plt.savefig("plots/plots_raw_log/"+label+".pdf")
plt.clf()
SigWeight=data.loc[data['Label']=="s",["Weight"]]
SigWeight=SigWeight.astype(float)
SigWeight=SigWeight.to_numpy()
SigWeight=SigWeight.reshape(-1,)
plt.hist(SigWeight,100,label="signal",alpha=0.5,facecolor="red")
plt.xlabel("signal weight")
plt.ylabel("distribution")
plt.savefig("plots/plots_raw/signalWeight.pdf")
plt.clf()
BkgWeight=data.loc[data['Label']=="b",["Weight"]]
BkgWeight=BkgWeight.astype(float)
BkgWeight=BkgWeight.to_numpy()
BkgWeight=BkgWeight.reshape(-1,)
plt.hist(BkgWeight,100,label="background",alpha=0.5,facecolor="green")
plt.xlabel("background weight")
plt.ylabel("distribution")
plt.savefig("plots/plots_raw/backgroundWeight.pdf")
plt.clf()
SigWeight=data.loc[data['Label']=="s",["Weight"]]