예제 #1
0
    def get_user_global_predict(self, test_dataset=None):

        if test_dataset is None:
            preprocess = DataPreprocess()
            test_dataset = preprocess.generate_test_data(batch_size=512)
            # test_dataset = test_dataset.take(1)

        container = np.random.choice(self.containers)
        SERVER_URL = container + self.model_url

        pred_y = []
        true_y = []
        for test_x, test_y in test_dataset:
            input_x = get_input_data(test_x)

            data = {"inputs": input_x}
            input_data_json = json.dumps(data)
            response = requests.post(SERVER_URL, data=input_data_json)
            response = json.loads(response.text)
            array = np.array(response['outputs'])

            _array = np.where(array > 0.5, 1, 0)
            pred_y.extend(_array)
            true_y.extend(test_y.numpy()[:, np.newaxis])

        get_metrics(true_y, pred_y, is_print=True)
예제 #2
0
    def predict(self, test_dataset=None, is_print=True):

        if test_dataset is None:
            test_dataset = self.data_process.generate_test_data()

        true_y = []
        pred_y = []
        for test_x, test_y in test_dataset:
            data = get_input_tensor_data(test_x)
            array = self.deepfm_model(data, training=False)
            _array = np.where(array > 0.5, 1, 0)
            pred_y.extend(_array)
            true_y.extend(test_y.numpy()[:, np.newaxis])

        get_metrics(true_y, pred_y, is_print=is_print)