def transform_fn()

in autogluon-tab-with-test.py [0:0]


def transform_fn(net, data, input_content_type, output_content_type):
  """
  Transform a request using the Gluon model. Called once per request.
  :param net: The AutoGluon model.
  :param data: The request payload.
  :param input_content_type: The request content type.
  :param output_content_type: The (desired) response content type.
  :return: response payload and content type.
  """
  # we can use content types to vary input/output handling, but
  # here we just assume json for both
  data = json.loads(data)
  # the input request payload has to be deserialized twice since it has a discrete header
  data = json.loads(data)
  df_parsed = pd.DataFrame(data)

  prediction = net.predict(df_parsed)

  response_body = json.dumps(prediction.tolist())

  return response_body, output_content_type