Python data_utils.prepare_data() Examples

The following are 2 code examples of data_utils.prepare_data(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module data_utils , or try the search function .
Example #1
Source File: ptrnets.py    From deeptravel with MIT License 6 votes vote down vote up
def ch_eva(f_encode, f_probi, prepare_data, data, iterator, options):
    accuracy = 0.0
    counter = 0.0
    area = 0.0
    for _, valid_index in iterator:
        chv = [data[t] for t in valid_index]
        v, vm, vx, vxm, vy, vym = prepare_data(chv)
        r = gen_hull(v, vm, f_encode, f_probi, options)
        hull_idx = r
        for s in range(hull_idx.shape[0]):
            acc, area_per = hull_accuracy(v[:, s, :], hull_idx[s, :], vy[:, s])
            if acc >= 0:
                accuracy += acc
                counter += 1
                area += area_per
    if counter > 0:
        return 1 - accuracy / len(data), counter / len(data), area / counter
    return 1.0, 0.0, 0.0 
Example #2
Source File: ptrnets.py    From deeptravel with MIT License 5 votes vote down vote up
def tsp_eva(f_encode, f_probi, prepare_data, data, iterator, options):
    len_sum = 0
    for _, valid_index in iterator:
        tspv = [data[t] for t in valid_index]
        v, vm, vx, vxm, vy, vym = prepare_data(tspv)
        r, c = gen_model(v, vm, f_encode, f_probi, options)
        route = r[0]
        # routes.extend(route)
        for s in range(route.shape[0]):
            len_sum += tour_length(v[:, s, :], route[s])
    len_sum /= len(data)
    return len_sum