Skip to content

Commit

Permalink
use feature_names parameter in mlflowserver predict function and call…
Browse files Browse the repository at this point in the history
… mlflows predict function with a DataFrame
  • Loading branch information
meori lehr authored and seldondev committed Jul 20, 2020
1 parent 296d024 commit 94538b4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions servers/mlflowserver/mlflowserver/MLFlowServer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import logging
import requests
import pandas as pd
from mlflow import pyfunc
from seldon_core import Storage
from seldon_core.user_model import SeldonComponent
Expand Down Expand Up @@ -33,8 +34,11 @@ def predict(

if not self.ready:
raise requests.HTTPError("Model not loaded yet")

result = self._model.predict(X)
if feature_names is not None and len(feature_names) > 0:
df = pd.DataFrame(data=X, columns=feature_names)
else:
df = pd.DataFrame(data=X)
result = self._model.predict(df)
logger.info(f"Prediction result: {result}")
return result

Expand Down

0 comments on commit 94538b4

Please sign in to comment.