-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevaluate_new_data.py
executable file
·53 lines (38 loc) · 1.43 KB
/
evaluate_new_data.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
# evaluate_new_data.py
# Copyright 2019 Robert Jones [email protected] Craic Computing LLC
# This software is made freely available under the terms of the MIT license
# Given a file of new data records (in test format) and a file of prediction results, output a list of IDs that are predicted to be positive
import os
import argparse
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--tsv", required=True, help="path to training format TSV file")
ap.add_argument("--results", required=True, help="path to prediction results")
args = vars(ap.parse_args())
test_tsv_file = args["tsv"]
results_file = args["results"]
ids = []
results = []
i = 0
with open(test_tsv_file, 'r') as f:
for line in f:
if i == 0:
i += 1
continue
fields = line.rstrip().split("\t")
ids.append(fields[0])
with open(results_file, 'r') as f:
for line in f:
fields = line.rstrip().split("\t")
neg_prob = float(fields[0])
pos_prob = float(fields[1])
result = 0
if pos_prob > neg_prob:
result = 1
results.append(result)
# merge the list of ids with the list of results - only output the positive hits
for i in range(len(ids)):
if results[i] == 1:
print(ids[i])
if __name__ == "__main__":
main()