示例#1
0
def combined_1D_onehot(DataCenter, folder_paths, samples = 4):
    folder_paths = np.array(folder_paths)

    channels = folder_paths.shape[0]

    plot = research.SubPlot(samples, channels)

    update_plot = 1

    # Iterate over all samples
    for sample in range(samples):

        for channel in range(channels):

            one_hot_labels = data.load_data(folder_paths[channel] + 'one_hot_labels.csv')
            max_curves = data.load_data(folder_paths[channel] + 'max_array_record.csv')
            min_curves = data.load_data(folder_paths[channel] + 'min_array_record.csv')

            participants = max_curves[:, 0]

            max_curves = max_curves[:, 1:]
            min_curves = min_curves[:, 1:]

            # Randomly Select Input Data
            rand_idx = np.random.randint(DataCenter.all_input_data.shape[0])

            # Get Output idx
            output_idx = np.argmax(DataCenter.all_output_data[rand_idx])

            # Get Participant ID from One Hot Labels
            participant = one_hot_labels[output_idx]

            curve_id = np.array(np.where(participants == participant))[0][0]

            max_curve = np.divide(max_curves[curve_id],DataCenter.input_scale[channel])
            min_curve = np.divide(min_curves[curve_id], DataCenter.input_scale[channel])

            # Plot Max/Min Curves
            plot.current_plot = update_plot
            plot.add_subplot_data(max_curve, add_data_to=update_plot, color='black')
            plot.add_subplot_data(min_curve, add_data_to=update_plot, color='black')

            # Plot Input Data
            input_data = DataCenter.all_input_data[rand_idx][:,channel]
            plot.add_subplot_data(input_data, add_data_to=update_plot, color='blue')

            update_plot += 1

    plot.show_plow()
示例#2
0
    def load_all_data_multiple(self, data_folder, data_files):
        print('Loading Data from multiple CSV files')
        print('Loading from {}. {} Left'.format(data_folder + data_files[0],
                                                len(data_files)))
        self.data_location = data_folder
        self.all_data = data.load_data(data_folder + data_files[0])
        print('Current Samples = {}'.format(self.all_data.shape[0]))

        for i in range(1, len(data_files)):
            print('Loading from {}. {} Left'.format(
                data_folder + data_files[i],
                len(data_files) - i))
            new_data = data.load_data(data_folder + data_files[i])
            self.all_data = np.concatenate([self.all_data, new_data], axis=0)
            print('Current Samples = {}'.format(self.all_data.shape[0]))
示例#3
0
    def load_data(self):
        path = self.folder_path + self.file_prefix

        print('Loading data from {}'.format(path))
        self.train_input_data = np.load(path + 'training_input_data.npy')
        self.val_input_data = np.load(path + 'validation_input_data.npy')
        self.eval_input_data = np.load(path + 'evaluation_input_data.npy')

        self.train_output_data = np.load(path + 'training_output_data.npy')
        self.val_output_data = np.load(path + 'validation_output_data.npy')
        self.eval_output_data = np.load(path + 'evaluation_output_data.npy')

        try:
            self.one_hot_labels = data.load_data(self.folder_path +
                                                 self.file_prefix +
                                                 'one_hot_labels.csv')
        except:
            'No one-hot labels'

        self.print_num_samples()
示例#4
0
 def load_all_data_single(self, data_folder, data_file):
     print('Loading Data from CSV file')
     self.data_location = data_folder
     self.all_data = data.load_data(data_folder + data_file)
     self.all_data = np.nan_to_num(self.all_data)