Ejemplo n.º 1
0
def ha_prediction_taxiBJ():
    DATAPATH = '../data'
    nb_flow = 2  # i.e. inflow and outflow
    T = 48  # number timestamps per day
    len_test = T * 4 * 7  # number of timestamps to predict (four weeks)

    # load data
    data_all = []
    timestamps_all = list()
    for year in range(13, 17):
        fname = os.path.join(DATAPATH, 'TaxiBJ',
                             'BJ{}_M32x32_T30_InOut.h5'.format(year))
        print("file name: ", fname)
        data, timestamps = load_stdata(fname)
        # print(timestamps)
        # remove a certain day which does not have 48 timestamps
        data, timestamps = remove_incomplete_days(data, timestamps, T)
        data = data[:, :nb_flow]
        data[data < 0] = 0.
        data_all.append(data)
        timestamps_all.append(timestamps)
    timestamps_all = [timestamp for l in timestamps_all for timestamp in l]
    data_all = np.vstack(copy(data_all))
    print('data shape: ' + str(data_all.shape))

    # make predictions
    predicted_data = ha_prediction(data_all, timestamps_all, T, len_test)

    # evaluate
    print('Evaluating on TaxiBJ')
    real_data = data_all[-len_test:]
    score = evaluate(real_data, predicted_data)

    # save to csv
    save_to_csv('HA', 'TaxiBJ', score)
Ejemplo n.º 2
0
def ha_prediction_bikeNYC():
    DATAPATH = '../data'
    nb_flow = 2  # i.e. inflow and outflow
    T = 24  # number timestamps per day
    len_test = T * 10  # number of timestamps to predict (ten days)

    # load data
    fname = os.path.join(DATAPATH, 'BikeNYC', 'NYC14_M16x8_T60_NewEnd.h5')
    print("file name: ", fname)
    data, timestamps = load_stdata(fname)
    # print(timestamps)
    # remove a certain day which does not have 48 timestamps
    data, timestamps = remove_incomplete_days(data, timestamps, T)
    data = data[:, :nb_flow]
    data[data < 0] = 0.
    print('data shape: ' + str(data.shape))

    # make predictions
    predicted_data = ha_prediction(data, timestamps, T, len_test)

    # evaluate
    print('Evaluating on BikeNYC')
    real_data = data[-len_test:]
    score = evaluate(real_data, predicted_data)

    # plot real vs prediction data of a region
    # plot_region_data(real_data, predicted_data, (13,3), 0)

    # save to csv
    save_to_csv('HA', 'BikeNYC', score)
Ejemplo n.º 3
0
def ha_prediction_RomaNord16x8():
    datapath = '../data'
    nb_flow = 2  # i.e. inflow and outflow
    T = 24  # number timestamps per day
    len_test = T * 7  # number of timestamps to predict

    # load data
    fname = os.path.join(datapath, 'Roma', 'AllMap',
                         'Roma_16x8_1_ora_resize_north.h5')

    print("file name: ", fname)
    data, timestamps = load_stdata(fname)
    # timestamps = np.array([adjust_timeslots(t) for t in timestamps])

    # print(timestamps)
    # remove a certain day which does not have 48 timestamps
    data, timestamps = remove_incomplete_days(data, timestamps, T)
    data = data[:, :nb_flow]
    data[data < 0] = 0.
    print('data shape: ' + str(data.shape))

    # make predictions
    predicted_data = ha_prediction(data, timestamps, T, len_test)

    # evaluate
    print('Evaluating on RomaNord16x8')
    real_data = data[-len_test:]
    score = evaluate(real_data, predicted_data)

    # plot real vs prediction data of a region
    # plot_region_data(real_data, predicted_data, (13,3), 0)

    # save to csv
    save_to_csv('HA', 'RomaNord16x8', score)