parameters: (self, json_data)
return_statement: return result
docstring: Make inference with the current Session object and JSON request data.
          
      Args:
        json_data: The JSON serialized object with key and array data.
                   Example is {"model_version": 1, "data": {"keys": [[1.0], [2.0]], "features": [[10, 10, 10, 8, 6, 1, 8, 9, 1], [6, 2, 1, 1, 1, 1, 7, 1, 1]]}}.
      Return:
        The dictionary with key and array data.
        Example is {"keys": [[11], [2]], "softmax": [[0.61554497, 0.38445505], [0.61554497, 0.38445505]], "prediction": [0, 0]}.
docstring_summary: Make inference with the current Session object and JSON request data.
          
      Args:
        json_data: The JSON serialized object with key and array data.
                   Example is {"model_version": 1, "data": {"keys": [[1.0], [2.0]], "features": [[10, 10, 10, 8, 6, 1, 8, 9, 1], [6, 2, 1, 1, 1, 1, 7, 1, 1]]}}.
      Return:
        The dictionary with key and array data.
        Example is {"keys": [[11], [2]], "softmax": [[0.61554497, 0.38445505], [0.61554497, 0.38445505]], "prediction": [0, 0]}.
docstring_tokens: Make inference with the current Session object and JSON request data . Args : json_data : The JSON serialized object with key and array data . Example is { model_version : 1 data : { keys : [[ 1 . 0 ] [ 2 . 0 ]] features : [[ 10 10 10 8 6 1 8 9 1 ] [ 6 2 1 1 1 1 7 1 1 ]] }} . Return : The dictionary with key and array data . Example is { keys : [[ 11 ] [ 2 ]] softmax : [[ 0 . 61554497 0 . 38445505 ] [ 0 . 61554497 0 . 38445505 ]] prediction : [ 0 0 ] } .
function: def inference(self, json_data):
      """
      Make inference with the current Session object and JSON request data.
          
      Args:
        json_data: The JSON serialized object with key and array data.
                   Example is {"model_version": 1, "data": {"keys": [[1.0], [2.0]], "features": [[10, 10, 10, 8, 6, 1, 8, 9, 1], [6, 2, 1, 1, 1, 1, 7, 1, 1]]}}.
      Return:
        The dictionary with key and array data.
        Example is {"keys": [[11], [2]], "softmax": [[0.61554497, 0.38445505], [0.61554497, 0.38445505]], "prediction": [0, 0]}.
      """
  
      # 1. Build inference data
      import xgboost as xgb
  
      input_data = json_data["data"]
      if json_data.get("preprocess", "false") != "false":
        if self.preprocess_function != None:
          input_data = self.preprocess_function(input_data)
          logger.debug("Preprocess to generate data: {}".format(input_data))
        else:
          logger.warning("No preprocess function in model")
  
      request_ndarray_data = xgb.DMatrix(np.array(input_data))
  
      # 2. Do inference
      start_time = time.time()
      predict_result = self.bst.predict(request_ndarray_data)
      logger.debug("Inference time: {} s".format(time.time() - start_time))
  
      if json_data.get("postprocess", "false") != "false":
        if self.postprocess_function != None:
          predict_result = self.postprocess_function(predict_result)
          logger.debug("Postprocess to generate data: {}".format(predict_result))
        else:
          logger.warning("No postprocess function in model")
  
      # 3. Build return data
      result = {
          "result": predict_result,
      }
      logger.debug("Inference result: {}".format(result))
  
      return result
function_tokens: def inference ( self , json_data ) : # 1. Build inference data import xgboost as xgb input_data = json_data [ "data" ] if json_data . get ( "preprocess" , "false" ) != "false" : if self . preprocess_function != None : input_data = self . preprocess_function ( input_data ) logger . debug ( "Preprocess to generate data: {}" . format ( input_data ) ) else : logger . warning ( "No preprocess function in model" ) request_ndarray_data = xgb . DMatrix ( np . array ( input_data ) ) # 2. Do inference start_time = time . time ( ) predict_result = self . bst . predict ( request_ndarray_data ) logger . debug ( "Inference time: {} s" . format ( time . time ( ) - start_time ) ) if json_data . get ( "postprocess" , "false" ) != "false" : if self . postprocess_function != None : predict_result = self . postprocess_function ( predict_result ) logger . debug ( "Postprocess to generate data: {}" . format ( predict_result ) ) else : logger . warning ( "No postprocess function in model" ) # 3. Build return data result = { "result" : predict_result , } logger . debug ( "Inference result: {}" . format ( result ) ) return result