Example #1
0
    def predict(self, x_test):
        if self.verbose > 0:
            print("[{}] Predicting data of {}".format(self.name, x_test.shape))

        start_time = time.time()
        model_path = self.output_directory + 'best_model.hdf5'
        model = keras.models.load_model(model_path)
        y_pred = model.predict(x_test, batch_size=self.batch_size)
        # if return_df_metrics:
        #     y_pred = np.argmax(y_pred, axis=1)
        #     df_metrics = calculate_metrics(y_true, y_pred, 0.0)
        #     return df_metrics
        # else:
        #     test_duration = time.time() - start_time
        #     save_test_duration(self.output_directory + 'test_duration.csv', test_duration)
        #     return y_pred

        test_duration = time.time() - start_time
        save_test_duration(self.output_directory + 'test_duration.csv',
                           test_duration)

        if self.verbose > 0:
            print("[{}] Predicting completed, took {}s".format(
                self.name, test_duration))

        return y_pred, test_duration
Example #2
0
    def predict(self, x: np.array):
        """
        Do prediction using the regression model on x

        Inputs:
            x: data for prediction (num_examples, num_timestep, num_channels) or (num_examples, num_features)
        """
        print("[{}] Predicting data of {}".format(self.name, x.shape))

        start_time = time.perf_counter()

        if len(x.shape) == 3:
            x = x.reshape(x.shape[0], x.shape[1] * x.shape[2])

        y_pred = self.model.predict(x)

        test_duration = time.perf_counter() - start_time

        save_test_duration(self.output_directory + 'test_duration.csv',
                           test_duration)

        print("[{}] Predicting completed, took {}s".format(
            self.name, test_duration))

        return y_pred
    def predict(self, x):
        print('[{}] Predicting'.format(self.name))
        start_time = time.perf_counter()
        print('[{}] Applying kernels'.format(self.name))
        x_test_transform = apply_kernels(x, self.kernels)
        y_pred = self.regressor.predict(x_test_transform)

        test_duration = time.perf_counter() - start_time
        save_test_duration(self.output_directory + 'test_duration.csv',
                           test_duration)

        print("[{}] Predicting completed, took {}s".format(
            self.name, test_duration))

        return y_pred
Example #4
0
    def predict(self, x):
        print('[{}] Predicting'.format(self.name))
        start_time = time.perf_counter()
        model = tf.keras.models.load_model(self.output_directory +
                                           self.best_model_file)
        yhat = model.predict(x)

        tf.keras.backend.clear_session()
        test_duration = time.perf_counter() - start_time

        save_test_duration(self.output_directory + 'test_duration.csv',
                           test_duration)

        print('[{}] Prediction done!'.format(self.name))

        return yhat
    def predict(self, x_test):
        print("[{}] Predicting data of {}".format(self.name, x_test.shape))

        start_time = time.perf_counter()

        if len(x_test.shape) == 3:
            x_test = x_test.reshape(x_test.shape[0], x_test.shape[1] * x_test.shape[2])

        y_pred = self.model.predict(x_test)

        test_duration = time.perf_counter() - start_time

        save_test_duration(self.output_directory + 'test_duration.csv', test_duration)

        print("[{}] Predicting completed, took {}s".format(self.name, test_duration))

        return y_pred
Example #6
0
    def predict(self, x_test):
        if self.verbose > 0:
            print("[{}] Predicting data of {}".format(self.name, x_test.shape))

        start_time = time.time()
        model_path = self.output_directory + 'best_model.hdf5'
        model = keras.models.load_model(model_path)
        y_pred = model.predict(x_test)

        test_duration = time.time() - start_time
        self.test_duration = test_duration
        save_test_duration(self.output_directory + 'test_duration.csv', test_duration)

        if self.verbose > 0:
            print("[{}] Predicting completed, took {}s".format(self.name, test_duration))

        return y_pred, test_duration
Example #7
0
    def predict(self, x_test):
        if self.verbose > 0:
            print("[{}] Predicting data of {}".format(self.name, x_test.shape))

        start_time = time.time()

        y_pred = self.model.predict(x_test)

        test_duration = time.time() - start_time
        save_test_duration(self.output_directory + 'test_duration.csv',
                           test_duration)
        self.test_duration = test_duration

        if self.verbose > 0:
            print("[{}] Predicting completed, took {}s".format(
                self.name, test_duration))

        return y_pred, test_duration
Example #8
0
    def predict(self, x):
        """
        Do prediction with DL models

        Inputs:
            x: data for prediction (num_examples, num_timestep, num_channels)
        Outputs:
            y_pred: prediction
        """
        print('[{}] Predicting'.format(self.name))
        start_time = time.perf_counter()
        model = tf.keras.models.load_model(self.output_directory + self.best_model_file)
        yhat = model.predict(x)

        tf.keras.backend.clear_session()
        test_duration = time.perf_counter() - start_time

        save_test_duration(self.output_directory + 'test_duration.csv', test_duration)

        print('[{}] Prediction done!'.format(self.name))

        return yhat