-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlatextabs.py
More file actions
116 lines (95 loc) · 2.95 KB
/
latextabs.py
File metadata and controls
116 lines (95 loc) · 2.95 KB
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
import numpy as np
def header4classifiers(classifiers):
text = ""
text += "\\begin{table}[!ht]\n"
text += "\\centering\n"
text += "\\tiny\n"
text += "\\begin{tabular}{l|\n"
for i, clf in enumerate(classifiers):
text += "S[table-format=0.3, table-figures-uncertainty=1]%s\n" % (
"|" if i != len(classifiers)-1 else "}"
)
text += "\\toprule"
text += "\\bfseries Dataset &\n"
for i, clf in enumerate(classifiers):
text += "\\multicolumn{1}{c%s}{\\bfseries %s} %s\n" % (
"|" if i != len(classifiers)-1 else " ",
clf + " (%i)" % (i+1),
"&" if i != len(classifiers)-1 else "\\\\"
)
text += "\\midrule\n"
"""
\toprule
\bfseries Dataset &
\multicolumn{1}{c|}{\bfseries CLF1} &
\multicolumn{1}{c }{\bfseries CLF2} \\
\midrule
"""
return text
def row(dataset, scores, stds):
text = "\\emph{%s}" % dataset
for i in range(scores.shape[0]):
text += "& "
text += "%.3f(%i) " % (scores[i], int(stds[i]*1000))
text += "\\\\\n"
return text
def row_stats(dataset, dependency, scores, stds):
text = "\\ "
min_score = np.min(scores)
for i in range(scores.shape[0]):
text += "& "
a = np.where(dependency[i] == 0)[0]
# a = np.where(np.logical_and(dependency[i] == 0, scores[i]>min_score))[0]
for value in a:
if scores[i] < scores[value]:
a = a[a != value]
if a.size == scores.shape[0]-1:
text += "$_{all}$"
elif a.size == 0:
text += "$_{-}$"
else:
a += 1
text += "$_{" + ", ".join(["%i" % i for i in a]) + "}$"
text += "\\\\\n"
return text
def footer(caption):
text = ""
text += "\\bottomrule\n"
text += "\\end{tabular}\n"
text += "\\caption{%s}\n" % caption
text += "\\end{table}\n"
return text
def header4classifiers_ranks(classifiers):
text = ""
text += "\\begin{table}[!ht]\n"
text += "\\centering\n"
text += "\\scriptsize\n"
text += "\\begin{tabular}{c|\n"
for i, clf in enumerate(classifiers):
text += "S[table-format=0.3, table-figures-uncertainty=1]%s\n" % (
"|" if i != len(classifiers)-1 else "}"
)
text += "\\toprule"
text += "\\bfseries &\n"
for i, clf in enumerate(classifiers):
text += "\\multicolumn{1}{c%s}{\\bfseries %s} %s\n" % (
"|" if i != len(classifiers)-1 else " ",
clf + " (%i)" % (i+1),
"&" if i != len(classifiers)-1 else "\\\\"
)
text += "\\midrule\n"
"""
\toprule
\bfseries &
\multicolumn{1}{c|}{\bfseries CLF1} &
\multicolumn{1}{c }{\bfseries CLF2} \\
\midrule
"""
return text
def row_ranks(scores):
text = "\\emph{Mean rank}"
for i in range(scores.shape[0]):
text += "& "
text += "${%.3f}$ " % scores[i]
text += "\\\\\n"
return text