-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathagreement.py
executable file
·64 lines (56 loc) · 1.45 KB
/
agreement.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
#!/usr/bin/env python3
import sqlite3
con = sqlite3.connect("results.sqlite3")
cur = con.cursor()
def agreement(table, filename_changed, max_match):
changed = "original<>changed" if filename_changed else "original=changed"
query = f"""
select
agree.cnt / cast(total.cnt as float) * 100.0
from
(
select
a, b, count(1) as cnt
from
(
select
a, b, original
from
{table}
where
{changed}
group by
a, b, original
having
sum(prediction) in(0, {max_match})
)
group by a, b
) as agree
join (
select
a,b,count(distinct original) as cnt
from
{table}
where
{changed}
group by a,b
) as total on
agree.a = total.a
and agree.b = total.b
"""
cur.execute(query)
return cur.fetchall()
print("Fraction of libraries where all predictors agree:")
print("-" * 70)
for t, m in (("two_predictors", 2), ("three_predictors", 3)):
print(f" {t}\n", "-" * 20)
for fnc in (True, False):
frac = []
for r in agreement(t, fnc, max_match=m):
frac.append(r[0])
print(
" {0:s}changed: avg: {1:.2f}%, min: {2:.2f}%, max: {3:.2f}%".format(
"" if fnc else "un", sum(frac) / len(frac), min(frac), max(frac)
)
)
print()