File size: 880 Bytes
e4cdf3c | 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 | """Offline CPU inference. Replace the frequency baseline with your own model."""
import argparse
import json
from pathlib import Path
import pandas as pd
from inputs import prepare_inputs
def predict_file(input_path, output_path):
root = Path(__file__).parent
frame = prepare_inputs(pd.read_parquet(input_path))
weights = json.loads((root / 'weights/baseline.json').read_text())
# Load your model once. Batch its predictions here.
with Path(output_path).open('w') as output:
for key in frame.id:
output.write(json.dumps({'id':key, 'prediction':weights['prediction']}) + '\n')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--input', required=True)
parser.add_argument('--output', required=True)
args = parser.parse_args()
predict_file(args.input, args.output)
|