🚧 Note
For more information on uploading a model artifact to Fiddler, see Uploading a Model Artifact.
import pickle
from pathlib import Path
import pandas as pd
from sklearn.linear_model import LogisticRegression
PACKAGE_PATH = Path(__file__).parent
OUTPUT_COLUMN = ['probability_over_50k']
class MyModel:
def __init__(self):
# Load the model
with open(PACKAGE_PATH / 'model.pkl', 'rb') as pkl_file:
self.model = pickle.load(pkl_file)
def predict(self, input_df):
# Store predictions in a DataFrame
return pd.DataFrame(self.model.predict_proba(input_df)[:, 1], columns=OUTPUT_COLUMN)
def get_model():
return MyModel()