forked from mlcommons/GaNDLF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gandlf_generateMetrics
71 lines (63 loc) · 1.99 KB
/
gandlf_generateMetrics
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
#!usr/bin/env python
# -*- coding: utf-8 -*-
import os
import argparse
import ast
import sys
from GANDLF import version
from GANDLF.cli import generate_metrics, copyrightMessage
if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog="GANDLF_Metrics",
formatter_class=argparse.RawTextHelpFormatter,
description="Metrics calculator.\n\n" + copyrightMessage,
)
parser.add_argument(
"-c",
"--config",
"--parameters_file",
metavar="",
type=str,
required=True,
help="The configuration file (contains all the information related to the training/inference session)",
)
parser.add_argument(
"-i",
"--inputdata",
"--data_path",
metavar="",
type=str,
required=True,
help="The CSV file of input data that is used to generate the metrics; should contain 3 columns: 'SubjectID,Target,Prediction'",
)
parser.add_argument(
"-o",
"--outputfile",
"--output_path",
metavar="",
type=str,
default=None,
help="Location to save the output dictionary. If not provided, will print to stdout.",
)
parser.add_argument(
"-v",
"--version",
action="version",
version="%(prog)s v{}".format(version) + "\n\n" + copyrightMessage,
help="Show program's version number and exit.",
)
# This is a dummy argument that exists to trigger MLCube mounting requirements.
# Do not remove.
parser.add_argument("-rawinput", "--rawinput", help=argparse.SUPPRESS)
args = parser.parse_args()
assert args.config is not None, "Missing required parameter: config"
assert args.inputdata is not None, "Missing required parameter: inputdata"
try:
generate_metrics.generate_metrics_dict(
args.inputdata,
args.config,
args.outputfile,
)
except Exception as e:
sys.exit("ERROR: " + str(e))
print("Finished.")