示例#1
0
def processData(data):
    data = pu.dropData(np.array([0, 0, 0, 0, 0, 0, 0, 0]), data)
    data = np.delete(data, [0, 1, 2], 0)
    data = pu.dropData(np.array([0, 0, 0, 0, 0, 0, 1, 0]), data)
    data = np.delete(data, [0, 1, 2], 0)
    data = pu.dropData(np.array([0, 1, 0, 0, 0, 0, 0, 1]), data)
    data = np.delete(data, [0, 1, 2], 0)
    data = pu.dropData(np.array([0, 0, 0, 0, 0, 0, 0, 1]), data)
    data = np.delete(data, [0, 1, 2], 0)
    data = pu.dropData(np.array([0, 0, 0, 0, 1, 0, 1, 0]), data)
    data = np.delete(data, [0, 1, 2], 0)
    gc.collect()
    #data = np.random.shuffle(data)
    print(data[:, 1].shape)
    full_X = data[:, 0]
    full_Y = data[:, 1]
    new_X = full_X[0][np.newaxis, ...]
    new_Y = full_Y[0][np.newaxis, ...]
    for i in range(full_Y.shape[0] - 1):
        new_Y = np.concatenate((new_Y, full_Y[i + 1][np.newaxis, ...]), axis=0)
        new_X = np.concatenate((new_X, full_X[i][np.newaxis, ...]), axis=0)

    new_data = [np.array(new_X), np.array(new_Y)]
    #new_data = pu.qualifyData(new_data)
    print(new_data[0].shape)
    print(new_data[1].shape)
    return new_data
    for i in range(full_X.shape[0]):
        if i == 0:
            addArray = full_X[i]
            new_X = addArray[np.newaxis, ...]
        if i == 1:
            addArray = full_X[i]
            print("test")
            print(addArray.shape)
            print(new_X.shape)
            new_X = np.concatenate((new_X, addArray[np.newaxis, ...]), axis=0)
        if i > 1:
            addArray = full_X[i]
            print("test")
            print(new_X.shape)
            new_X = np.concatenate((new_X, addArray[np.newaxis, ...]), axis=0)
    for i in range(full_Y.shape[0]):
        if i == 0:
            addArray = full_Y[i]
            new_Y = addArray[np.newaxis, ...]
        if i == 1:
            addArray = full_Y[i]
            print("test")
            print(addArray.shape)
            print(new_Y.shape)
            new_Y = np.concatenate((new_Y, addArray[np.newaxis, ...]), axis=0)
        if i > 1:
            addArray = full_Y[i]
            print("test")
            print(new_Y.shape)
            new_Y = np.concatenate((new_Y, addArray[np.newaxis, ...]), axis=0)
def processData(data):
    data = pu.dropData(np.array([0, 0, 0, 0, 0, 0, 0, 0]), data)
    data = np.delete(data, [0, 1], 0)
    data = pu.dropData(np.array([0, 0, 0, 0, 0, 0, 1, 0]), data)
    data = np.delete(data, [0, 1], 0)
    data = pu.dropData(np.array([0, 0, 0, 0, 0, 0, 0, 1]), data)
    data = np.delete(data, [0, 1], 0)
    gc.collect()
    #data = np.random.shuffle(data)
    print(data[:, 1].shape)
    full_X = data[:, 0]
    full_Y = data[:, 1]
    new_X = full_X[0][np.newaxis, ...]
    new_Y = full_Y[0][np.newaxis, ...]
    for i in range(full_Y.shape[0] - 1):
        new_Y = np.concatenate((new_Y, full_Y[i + 1][np.newaxis, ...]), axis=0)
        new_X = np.concatenate((new_X, full_X[i][np.newaxis, ...]), axis=0)

    split_x = np.array_split(new_X, new_X.shape[0] / 7)
    new_X = None
    gc.collect()
    X = None
    for element in split_x:
        if element.shape[0] != 7:
            continue
        if X is None:
            X = element[np.newaxis, ...]
        else:
            print(element.shape)
            print(X.shape)
            X = np.concatenate((X, element[np.newaxis, ...]), axis=0)

    split_y = np.array_split(new_Y, new_Y.shape[0] / 7)
    new_Y = None
    gc.collect()
    y = None
    for element in split_y:
        if element.shape[0] != 7:
            continue
        if y is None:
            y = element[np.newaxis, ...]
        else:
            print(element.shape)
            print(y.shape)
            y = np.concatenate((y, element[np.newaxis, ...]), axis=0)

    new_data = [np.array(X), np.array(y)]
    #new_data = pu.qualifyData(new_data)
    print(new_data[0].shape)
    print(new_data[1].shape)
    return new_data
def processData(data):
    data = pu.dropData(np.array([0, 0, 0, 0, 0, 0, 0, 0]), data)
    data = np.delete(data, [0, 1, 2], 0)
    data = pu.dropData(np.array([0, 0, 0, 0, 0, 0, 1, 0]), data)
    data = np.delete(data, [0, 1, 2], 0)
    data = pu.dropData(np.array([0, 1, 0, 0, 0, 0, 0, 1]), data)
    data = np.delete(data, [0, 1, 2], 0)
    data = pu.dropData(np.array([0, 0, 0, 0, 0, 0, 0, 1]), data)
    data = np.delete(data, [0, 1, 2], 0)
    data = pu.dropData(np.array([0, 0, 0, 0, 1, 0, 1, 0]), data)
    data = np.delete(data, [0, 1, 2], 0)
    gc.collect()
    #data = np.random.shuffle(data)
    print(data[:, 1].shape)
    full_X = data[:, 0]
    full_Y = data[:, 1]
    new_X = full_X[0][np.newaxis, ...]
    new_Y = full_Y[0][np.newaxis, ...]
    for i in range(full_Y.shape[0]):
        try:
            if not np.array_equal(full_Y[i], full_Y[i + 1]):
                for j in range(3):
                    index = j - 1
                    add_Y = full_Y[i + index]
                    add_X = full_X[i + index]
                    print(new_Y.shape)
                    print(add_Y[np.newaxis, ...].shape)
                    new_Y = np.concatenate((new_Y, add_Y[np.newaxis, ...]),
                                           axis=0)
                    new_X = np.concatenate((new_X, add_X[np.newaxis, ...]),
                                           axis=0)
            else:
                print("Skip")

        except:
            print("not posible")
        print(new_X.shape)

    new_data = [np.array(new_X), np.array(new_Y)]
    new_data = pu.qualifyData(new_data)
    print(new_data[0].shape)
    print(new_data[1].shape)
    return new_data
    for i in range(full_X.shape[0]):
        if i == 0:
            addArray = full_X[i]
            new_X = addArray[np.newaxis, ...]
        if i == 1:
            addArray = full_X[i]
            print("test")
            print(addArray.shape)
            print(new_X.shape)
            new_X = np.concatenate((new_X, addArray[np.newaxis, ...]), axis=0)
        if i > 1:
            addArray = full_X[i]
            print("test")
            print(new_X.shape)
            new_X = np.concatenate((new_X, addArray[np.newaxis, ...]), axis=0)
    for i in range(full_Y.shape[0]):
        if i == 0:
            addArray = full_Y[i]
            new_Y = addArray[np.newaxis, ...]
        if i == 1:
            addArray = full_Y[i]
            print("test")
            print(addArray.shape)
            print(new_Y.shape)
            new_Y = np.concatenate((new_Y, addArray[np.newaxis, ...]), axis=0)
        if i > 1:
            addArray = full_Y[i]
            print("test")
            print(new_Y.shape)
            new_Y = np.concatenate((new_Y, addArray[np.newaxis, ...]), axis=0)