Esempio n. 1
0
def generate_data_package(fold: int, tenfolds: list, regression: bool,
                          du: DataUtility):
    test_data, test_labels = copy.deepcopy(tenfolds[fold])
    remaining_data = [
        x[0] for i, x in enumerate(copy.deepcopy(tenfolds)) if i != fold
    ]
    remaining_labels = [
        y[1] for i, y in enumerate(copy.deepcopy(tenfolds)) if i != fold
    ]
    #Store off a set of the remaining dataset
    training_data = np.concatenate(remaining_data, axis=1)
    #Store the remaining data set labels
    training_labels = np.concatenate(remaining_labels, axis=1)

    if regression == True:
        #The number of output nodes is 1
        output_size = 1
    #else it is a classification data set
    else:
        #Count the number of classes in the label data set
        output_size = du.CountClasses(training_labels)
        #Get the test data labels in one hot encoding
        test_labels = du.ConvertLabels(test_labels, output_size)
        #Get the Labels into a One hot encoding
        training_labels = du.ConvertLabels(training_labels, output_size)

    input_size = training_data.shape[0]
    return [
        test_data, test_labels, training_data, training_labels, output_size,
        input_size
    ]
Esempio n. 2
0
def generate_data_package(fold: int, tenfolds: list, regression: bool, du: DataUtility):
    # get the fold we are going to use for testing 
    test_data, test_labels = copy.deepcopy(tenfolds[fold])
    # squish the rest of the data and ground truth labels into one numpy array, respectively
    remaining_data = [x[0] for i, x in enumerate(copy.deepcopy(tenfolds)) if i!=fold]
    remaining_labels = [y[1] for i, y in enumerate(copy.deepcopy(tenfolds)) if i!=fold]
    training_data = np.concatenate(remaining_data, axis=1) 
    training_labels = np.concatenate(remaining_labels, axis=1)
    # determine how many output nodes the network has (1 if regression)
    if regression == True:
        #The number of output nodes is 1 
        output_size = 1
    #else it is a classification data set 
    else:
        #Count the number of classes in the label data set 
        output_size = du.CountClasses(training_labels)
        #Get the test data labels in one hot encoding 
        test_labels = du.ConvertLabels(test_labels, output_size)
        #Get the Labels into a One hot encoding 
        training_labels = du.ConvertLabels(training_labels, output_size)

    input_size = training_data.shape[0]
    return [test_data, test_labels, training_data, training_labels, output_size, input_size]