Beispiel #1
0
def extract_frame_matrix_pre_label(filename, pre_timestep):
    # slide window: length = 1s; overlay = 50%
    # (samples, steps, data_dims)
    raw = pd.read_csv(filename)
    raw = pd.DataFrame(raw)
    start = 0
    end = start + 64
    frame_list = list()
    y = list()
    data_x, data_y = pre.process_dataset_file(np.array(raw))
    raw = np.hstack([data_x, np.reshape(data_y, [data_y.shape[0], 1])])
    row, _ = raw.shape
    while end < row:
        sample = raw[start:end, 1:19]
        label = raw[end - 1, -1]
        y.append(label)
        frame_list.append(sample)
        start = start + 32
        end = start + 64
    frame_list = np.array(frame_list)
    y = np.array(y)
    if len(y) <= pre_timestep:
        assert 'wrong timestep'
    frame_list = frame_list[0:-pre_timestep, :, :]
    y = y[pre_timestep:]
    return frame_list, y
Beispiel #2
0
def extract_frame_matrix_pre_label(filename, look_back):
    # slide window: length = 1s; overlay = 50%
    # (samples, steps, data_dims)
    raw = pd.read_csv(filename)
    raw = pd.DataFrame(raw)
    start = 0
    end = start + 64
    frame_list = list()
    y = list()
    data_x, data_y = pre.process_dataset_file(np.array(raw))
    raw = np.hstack([data_x, np.reshape(data_y, [data_y.shape[0], 1])])
    row, _ = raw.shape
    while end < row:
        sample = raw[start:end, 1:19]
        label = raw[end - 1, -1]
        y.append(label)
        frame_list.append(sample)
        start = start + 32
        end = start + 64
    frame_list = np.array(frame_list)
    y = np.array(y)
    if len(y) <= look_back:
        assert 'wrong timestep'
    frame_list = frame_list[0:-look_back, :, :]
    yy = np.zeros([frame_list.shape[0]])
    for i in range(frame_list.shape[0]):
        yy[i] = 1 if 1 in y[i + 1:i + look_back + 1] else 0
    return frame_list, yy
Beispiel #3
0
def extract_frame_matrix_sequential(filename, timestep):
    # slide window: length = 1s; overlay = 50%
    # (samples, steps, data_dims)
    raw = pd.read_csv(filename)
    raw = pd.DataFrame(raw)
    data_x, data_y = pre.process_dataset_file(np.array(raw))
    raw = np.hstack([data_x, np.reshape(data_y, [data_y.shape[0], 1])])
    row, _ = raw.shape
    least_length = 64 + (timestep - 1) * 32
    samples, lables = spilt_squential(
        raw, np.arange(0, raw.shape[0] - least_length, 32), timestep)
    # print(np.unique(lables))
    return samples, lables
Beispiel #4
0
def extract_frame_matrix(filename):
    # slide window: length = 1s; overlay = 50%
    raw = pd.read_csv(filename, header=None)
    raw = pd.DataFrame(raw)
    row, col = raw.shape
    start = 0
    end = start + 64
    frame_list = []
    y = []
    data_x, data_y = pre.process_dataset_file(np.array(raw))
    print(data_x.shape, data_y.shape)
    # raw = pd.DataFrame(np.hstack([data_x,data_y]))
    while end <= row:
        sample = raw.iloc[start:end, 1:10]
        sample = sample.as_matrix()
        label = raw.iloc[end - 1, -1]
        y.append(label)
        frame_list.extend(sample)
        start = start + 32
        end = start + 64
    return frame_list, y
Beispiel #5
0
def extract_frame_concatenate(filename):
    # slide window: length = 1s; overlay = 50%
    raw = pd.read_csv(filename, header=None)
    raw = pd.DataFrame(raw)
    row, col = raw.shape
    start = 0
    end = start + 64
    frame_list = list()
    y = list()
    data_x, data_y = pre.process_dataset_file(np.array(raw))
    raw = pd.DataFrame(
        np.hstack([data_x, np.reshape(data_y, [data_y.shape[0], 1])]))
    while end <= row:
        sample = raw.iloc[start:end, 1:19]
        sample = sample.as_matrix()
        sample = sample.reshape((1, 64 * 18))
        label = raw.iloc[end, -1]
        y.append(label)
        frame_list.extend(sample)
        start = start + 32
        end = start + 64
    return frame_list, y