-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanl-plot.py
executable file
·105 lines (68 loc) · 2.42 KB
/
anl-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
__author__ = "Sitong An <[email protected]>"
import ROOT
import array
import math
def main():
f = open("baseline.result","r")
baselines = f.readlines()
f.close()
baselines = [line.split(",") for line in baselines]
(nvar, tauc_avg, tauc_error) = zip(*baselines)
nvar = [int(i) for i in nvar]
tauc_avg = [float(i) for i in tauc_avg]
tauc_error = [float(i) for i in tauc_error]
max_n_var=len(nvar)
leg= ROOT.TLegend(0.5, 0.2, 0.8, 0.35)
leg.SetBorderSize(0)
leg.SetFillColor(0)
leg.SetTextSize(0.025)
leg.SetTextFont(42)
x = array.array('f',range(1,max_n_var+1))
y = array.array('f',tauc_avg)
ye = array.array('f', tauc_error)
xe = array.array('f', [0]*max_n_var)
gr = ROOT.TGraphErrors(max_n_var, x, y,xe, ye)
gr.SetMarkerColor(38)
gr.SetLineColor(38)
gr.SetMarkerStyle(20)
gr.SetTitle("ROC Integral vs No. of Variables")
gr.GetXaxis().SetTitle("No. of Training Variables")
gr.GetYaxis().SetTitle("Relative Performance (AUROC)")
leg.AddEntry(gr, "#splitline{Reference Baseline}{(Randomly selected variable sets as basis of comparison)}", "p")
f = open("roc-tmva.result", "r")
lines = f.readlines()
f.close()
blabel = [float((l.split(",")[0]).split("-")[-1]) for l in lines]
bdata = [float((l.split(",")[-1])) for l in lines]
x2 = array.array('f', blabel)
y2 = array.array('f', bdata)
d = dict()
gr4 = plot_file("roc-tmva.result", 813, 813)
gr9 = plot_file("itrRm.result",905,905)
c1 = ROOT.TCanvas("c1", "Relative Performance (AUROC) vs No. of Training Variables", 950, 600)
gr.Draw("APL")
gr4.Draw("PL")
leg.AddEntry(gr4, "#splitline{TMVA out-of-the-box Ranking}{(Performance of top N vars as ranked by TMVA)}", "p")
leg.AddEntry(gr9, "#splitline{Iterative Removal - vSearch}{(Removing var with least impact on performance iteratively)}", "p")
leg.Draw()
print "press enter to continue\n"
raw_input()
def plot_file(filen, markercolor, linecolor, xfixed=0, markerstyle=20):
f = open(filen, "r")
lines = f.readlines()
f.close()
label = [float((l.split(",")[0]).split("-")[-1]) for l in lines]
data = [float((l.split(",")[-1])) for l in lines]
#print label
#print data
if xfixed: x2 = array.array('f', [float(xfixed)]*len(data))
else: x2 = array.array('f', label)
y2 = array.array('f', data)
print x2
gr3 = ROOT.TGraph(len(label), x2, y2)
gr3.SetMarkerColor(markercolor)
gr3.SetLineColor(linecolor)
gr3.SetMarkerStyle(markerstyle)
return gr3
if __name__ == '__main__':
main()