You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe not Real Applications, but a lot of demos will use data frames, so a scoring function that takes a data frame and returns one would be nice. This is a rough draft which needs to be cleaned up, but putting hear as a place holder for the ModelOps Utiliies
def get_predictions(rows: pd.DataFrame):
# handle nulls
rows = rows.where(pd.notnull(rows), "")
# every value needs to be a string
vals = rows.values.tolist()
for i in range(len(vals)):
vals[i] = [str(x) for x in vals[i]]
# create a string that is in the expected dictionary format
dictionary = '{"fields": ' + str(df.columns.tolist()) + ', "rows": ' + str(vals) + '}'
dictionary = dictionary.replace("'", '"'). #mlops needs double quotes!
# use the utility function
dict_preds = mlops_get_score('https://model.wave.h2o.ai/f2659e88-cbad-4ae0-baf0-e25daef42461/model/score',
dictionary)
# turn the returned dict into a dataframe
preds = pd.DataFrame(data=dict_preds['score'], columns=dict_preds['fields'])
# join with original data, assumption is the row order never changes
return pd.concat([rows, preds], axis=1)
The text was updated successfully, but these errors were encountered:
Maybe not Real Applications, but a lot of demos will use data frames, so a scoring function that takes a data frame and returns one would be nice. This is a rough draft which needs to be cleaned up, but putting hear as a place holder for the ModelOps Utiliies
The text was updated successfully, but these errors were encountered: