clearing queries
clearing queries

Reputation: 1

Error while evaluating the model. Verify that the serialized input Dataframe is compatible with the model for inference. I am using SDV ctgan model

class Model_Wrapper(mlflow.pyfunc.PythonModel):

    def __init__(self,):
      self.model = None

    def load_context(self,context):
        self.model=mlflow.pyfunc.load_model(context.artifacts["Original_Model"])

    def predict(self, context, model_input):
       ss = self.model.sample(int(model_input.get("records")[0]))
       return ss.to_json()


input format:
invocations url  post method : {"inputs":{"records":[2]}}

error screenshot

Input to the invocation url is as expected and in the format of mlflow keywords. Output expected is dataframe.

Upvotes: 0

Views: 50

Answers (1)

clearing queries
clearing queries

Reputation: 1

Use the code as it is... don't do any changes:

 def predict(self, context, model_input):                                                                    
    tempPath = f"temp.{model_input.get("records")[0]}.csv"
     ss = self.model.sample(int(model_input.get("records")[0]),output_file_path=tempPath)
     if os.path.exists(tempPath):
           os.remove(tempPath)                                                                                                                                                                                 
     return ss.to_json()

Upvotes: 0

Related Questions