ium_444356/predict.py
Maciej Czajka acaf964f41
Some checks reported errors
s444356-evaluation/pipeline/head This commit looks good
s444356-training/pipeline/head Something is wrong with the build of this commit
update predict.py
2022-05-11 20:03:13 +02:00

31 lines
719 B
Python

#import json
#import mlflow
#import sys
#input = sys.argv[1]
#logged_model = 'mlruns/1/3630068c31924c05a9a04e70ef35e0b8/artifacts/s444409'
#loaded_model = mlflow.pyfunc.load_model(logged_model)
#with open(f'{logged_model}/'+input) as f:
# data = json.load(f)
#loaded_model.predict(data['inputs'])
import json
import mlflow
import numpy as np
input = sys.argv[1]
logged_model = 'mlruns/1/296d6f314bb2451885fb7ae58988301e/artifacts/model'
loaded_model = mlflow.pyfunc.load_model(logged_model)
with open(f'{logged_model}/'+str(input)) as f:
data = json.load(f)
input_example = np.array([data['inputs'][0]], dtype=np.float64).reshape(-1, 2)
print(f'Prediction: {loaded_model.predict(input_example)}')