ium_444417/lab8/predictMlflow.py
s444417 f5175a9517
All checks were successful
s444417-training/pipeline/head This commit looks good
s444417-evaluation/pipeline/head This commit looks good
reshape
2022-05-15 11:05:05 +02:00

30 lines
895 B
Python

# import mlflow
# import numpy as np
# import json
#
# logged_model = '/mlruns/14/80fe21a0804844088147d15a3cebb3e5/artifacts/lego-model'
#
# # Load model as a PyFuncModel.
# loaded_model = mlflow.pyfunc.load_model(logged_model)
#
# with open(f'{loaded_model}/input_example.json') as f:
# input_example_data = json.load(f)
#
# # Predictions
# print(f'input: {input_example_data}')
# print(f'predictions: {loaded_model.predict(input_example_data)}')
import mlflow
import numpy as np
import json
registry_path = '/mlruns/14/80fe21a0804844088147d15a3cebb3e5/artifacts/lego-model'
model = mlflow.pyfunc.load_model(registry_path)
with open(f'{registry_path}/input_example.json') as f:
input_example_data = json.load(f)
input_example = np.array(input_example_data['inputs']).reshape(-1,)
print(f'Input: {input_example}')
print(f'Prediction: {model.predict(input_example)}')