2022-05-11 20:49:26 +02:00
|
|
|
import mlflow
|
2022-05-11 20:55:45 +02:00
|
|
|
import json
|
|
|
|
import numpy as np
|
2022-05-11 20:49:26 +02:00
|
|
|
logged_model = '/mlruns/12/1c2b9737c0204b0ca825811c35fb6c64/artifacts/s444409'
|
|
|
|
|
|
|
|
# Load model as a PyFuncModel.
|
|
|
|
loaded_model = mlflow.pyfunc.load_model(logged_model)
|
|
|
|
|
2022-05-11 20:55:45 +02:00
|
|
|
with open(f'{logged_model}/input_example.json') as f:
|
|
|
|
data = json.load(f)
|
|
|
|
input_example = np.array([data['inputs'][0]], dtype=np.float32)
|
|
|
|
|
2022-05-11 20:49:26 +02:00
|
|
|
# Predict on a Pandas DataFrame.
|
|
|
|
import pandas as pd
|
2022-05-11 20:55:45 +02:00
|
|
|
print(f'Prediction: {loaded_model.predict(input_example)}')
|