diff --git a/jpmml_evaluator/__main__.py b/jpmml_evaluator/__main__.py new file mode 100644 index 0000000..9baaefc --- /dev/null +++ b/jpmml_evaluator/__main__.py @@ -0,0 +1,4 @@ +from jpmml_evaluator.cli import main + +if __name__ == "__main__": + main() diff --git a/jpmml_evaluator/cli.py b/jpmml_evaluator/cli.py new file mode 100644 index 0000000..f10a7a6 --- /dev/null +++ b/jpmml_evaluator/cli.py @@ -0,0 +1,33 @@ +import sys + +from argparse import ArgumentParser + +import pandas + +from jpmml_evaluator import make_evaluator + +def main(): + parser = ArgumentParser(description = "JPMML-Evaluator command-line application") + parser.add_argument("model", type = str, help = "Model PMML file") + parser.add_argument("-i", "--input", type = str, help = "Input CSV file") + parser.add_argument("-o", "--output", type = str, help = "Output CSV file") + parser.add_argument("--sep", type = str, default = ",", help = "CSV separator character") + + args = parser.parse_args() + + evaluator = make_evaluator(args.model) + evaluator.verify() + + if args.input: + input = args.input + else: + input = sys.stdin + + if args.output: + output = args.output + else: + output = sys.stdout + + arguments = pandas.read_csv(input, sep = args.sep) + results = evaluator.evaluateAll(arguments) + results.to_csv(output, sep = args.sep, header = True, index = False)