Skip to content

Commit

Permalink
Added command-line interface
Browse files Browse the repository at this point in the history
  • Loading branch information
vruusmann committed Nov 27, 2024
1 parent 8b24764 commit 136ed4a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions jpmml_evaluator/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from jpmml_evaluator.cli import main

if __name__ == "__main__":
main()
33 changes: 33 additions & 0 deletions jpmml_evaluator/cli.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 136ed4a

Please sign in to comment.