Hi all.
My colleagues from other department created and "learned" a model with just Python code and stored it as a pickle object in a file.
Now I want to import that model from pickle file and use it in Embedded Python Execution script.
Is this possible at all?
If it is possible, then can you give me an example, how that can be done?
Also can I import other pickle objects from files and use them also for OML4Py, for example, pickle file with variables in some data structure?
Code that I want to execute with Embedded Python Execution, where I want to have somehow pickled objects:
import pandas as pd
import pickle
import numpy as np
def preprocess_data(df) -> pd.DataFrame:
# some logic with df variable
return df
def ml_model_predict(df: pd.DataFrame) -> pd.DataFrame:
df_clean = preprocess_data(df)
model = pickle.load(open('/path_to/dummy_model.pkl', 'rb'))
exp_vars = pickle.load(open('/path_to/dummy_model_vars.pkl', 'rb'))
df_clean["model_pred"] = model.predict(df_clean[exp_vars])
return df_clean[["property1", "model_pred"]]
Thank you!