-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.py
53 lines (42 loc) · 1.62 KB
/
train.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
#!/usr/bin/env python
import shlex
import sys
import argparse
import pathlib
import pandas as pd
import pickle
from m6arp.models.ours import interface as m6arp
from m6arp.loading import get_randomized_data, separate_data_and_labels
def parse_args():
parser = argparse.ArgumentParser(description='Train a model.')
parser.add_argument('--site',
required=True,
type=int,
help='The site for which the model should learn to make predictions.')
parser.add_argument('--positive-csv',
required=True,
type=pathlib.Path,
help='The csv file with positive example reads and values per position for training.')
parser.add_argument('--negative-csv',
required=True,
type=pathlib.Path,
help='The csv file with negative example reads and values per position for training.')
parser.add_argument('--output',
type=pathlib.Path,
help='The path at which to output the trained model.')
args = parser.parse_args()
return args
def main() -> int:
"""Run model with given arguments."""
args = parse_args()
Xy_df = get_randomized_data(args.site, args.positive_csv, args.negative_csv)
X, y = separate_data_and_labels(Xy_df)
classifier = m6arp.trained_classifier(X, y)
if args.output:
with open(args.output, "wb") as f:
pickle.dump(classifier, f)
else:
print(classifier)
return 0
if __name__ == '__main__':
sys.exit(main())