Ejemplo n.º 1
0
    x_values = []
    y_values1 = []
    y_values2 = []
    y_values3 = []

    # data, axis_users, axis_pois, check_data = init_data(region, filter_count, train_percent)
    data, axis_users, axis_pois, check_data = init_data_by_user(
        tuple([0, 3, 4, 5, 30]), filter_count, train_percent)
    user_num = len(axis_users)
    poi_num = len(axis_pois)

    init_tensor = [[[
        1 / (poi_num * time_num * user_num) for i in range(poi_num)
    ] for j in range(time_num)] for k in range(user_num)]
    transition_tensor = inreducible_tensor(mtt(data, user_num, poi_num),
                                           user_num, time_num, poi_num, alpha)
    res1, iterator_values1 = tensor_three_mode_product(transition_tensor,
                                                       init_tensor)

    order = 1
    while order <= settings.ITERATOR_NUMBER:
        x_values.append(order)
        y_values1.append(iterator_values1[order])
        order += 1

    label = "" + str(((settings.TIME_SLICE * user_num * poi_num)**2))
    pylab.plot(x_values,
               y_values1,
               'rs',
               linewidth=1,
               linestyle="-",
Ejemplo n.º 2
0
if __name__ == '__main__':
    # beijing = (39.433333, 41.05, 115.416667, 117.5)
    # haidian = (39.883333, 40.15, 116.05, 116.383333)
    region = (39.883333, 40.05, 116.05, 116.383333)
    filter_count = 600
    alpha = 0.8
    alpha_shift = 0.1

    data, axis_users, axis_pois, check_data = init_data(region, filter_count)
    user_num = len(axis_users)
    time_num = settings.TIME_SLICE
    poi_num = len(axis_pois)

    transition_tensor = mtt(data, user_num, poi_num)
    transition_tensor2 = inreducible_tensor(transition_tensor, user_num, time_num, poi_num, alpha)
    transition_tensor3 = mtt(data, user_num, poi_num, zero_adjustment=False)

    # equal_all_sum_one: equal
    # init_tensor1 = [[[1/(poi_num * time_num * user_num) for i in range(poi_num)] for j in range(time_num)] for k in range(user_num)]
    # # random_all_sum_one: no zero element
    # temp_tensor = [[[random.choice([1, 2, 3, 100]) for i in range(poi_num)] for j in range(time_num)] for k in range(user_num)]
    # init_tensor2 = three_tensor_hadarmard(1/three_order_tensor_first_norm(temp_tensor), temp_tensor)
    #
    # init_tensor3 = [[[0 for i in range(poi_num)] for j in range(time_num)] for k in range(user_num)]
    # init_tensor3[0][0][0] = 1
    # # random_all_sum_one: exist zero element
    # temp_tensor = [[[random.choice([0, 1, 2, 3, 4]) for i in range(poi_num)] for j in range(time_num)] for k in range(user_num)]
    # init_tensor3 = three_tensor_hadarmard(1/three_order_tensor_first_norm(temp_tensor), temp_tensor)
    # # user_slice_sum_one: equal
    # init_tensor4 = [[[1/(poi_num * time_num) for i in range(poi_num)] for j in range(time_num)] for k in range(user_num)]
Ejemplo n.º 3
0
    time_num = settings.TIME_SLICE
    train_percent = 0.95
    alpha = 0.95

    x_values = []
    y_values1 = []
    y_values2 = []
    y_values3 = []

    # data, axis_users, axis_pois, check_data = init_data(region, filter_count, train_percent)
    data, axis_users, axis_pois, check_data = init_data_by_user(tuple([0, 3, 4, 5, 30]), filter_count, train_percent)
    user_num = len(axis_users)
    poi_num = len(axis_pois)

    init_tensor = [[[1/(poi_num * time_num * user_num) for i in range(poi_num)] for j in range(time_num)] for k in range(user_num)]
    transition_tensor = inreducible_tensor(mtt(data, user_num, poi_num), user_num, time_num, poi_num, alpha)
    res1, iterator_values1 = tensor_three_mode_product(transition_tensor, init_tensor)

    order = 1
    while order <= settings.ITERATOR_NUMBER:
        x_values.append(order)
        y_values1.append(iterator_values1[order])
        order += 1

    label = ""+str(((settings.TIME_SLICE*user_num*poi_num)**2))
    pylab.plot(x_values, y_values1, 'rs', linewidth=1, linestyle="-", label=label)


    data, axis_users, axis_pois, check_data = init_data_by_user(tuple([0, 3, 4]), filter_count, train_percent)
    user_num = len(axis_users)
    poi_num = len(axis_pois)
Ejemplo n.º 4
0
if __name__ == '__main__':
    # beijing = (39.433333, 41.05, 115.416667, 117.5)
    # haidian = (39.883333, 40.15, 116.05, 116.383333)
    region = (39.883333, 40.05, 116.05, 116.383333)
    filter_count = 600
    alpha = 0.8
    alpha_shift = 0.1

    data, axis_users, axis_pois, check_data = init_data(region, filter_count)
    user_num = len(axis_users)
    time_num = settings.TIME_SLICE
    poi_num = len(axis_pois)

    transition_tensor = mtt(data, user_num, poi_num)
    transition_tensor2 = inreducible_tensor(transition_tensor, user_num,
                                            time_num, poi_num, alpha)
    transition_tensor3 = mtt(data, user_num, poi_num, zero_adjustment=False)

    # equal_all_sum_one: equal
    # init_tensor1 = [[[1/(poi_num * time_num * user_num) for i in range(poi_num)] for j in range(time_num)] for k in range(user_num)]
    # # random_all_sum_one: no zero element
    # temp_tensor = [[[random.choice([1, 2, 3, 100]) for i in range(poi_num)] for j in range(time_num)] for k in range(user_num)]
    # init_tensor2 = three_tensor_hadarmard(1/three_order_tensor_first_norm(temp_tensor), temp_tensor)
    #
    # init_tensor3 = [[[0 for i in range(poi_num)] for j in range(time_num)] for k in range(user_num)]
    # init_tensor3[0][0][0] = 1
    # # random_all_sum_one: exist zero element
    # temp_tensor = [[[random.choice([0, 1, 2, 3, 4]) for i in range(poi_num)] for j in range(time_num)] for k in range(user_num)]
    # init_tensor3 = three_tensor_hadarmard(1/three_order_tensor_first_norm(temp_tensor), temp_tensor)
    # # user_slice_sum_one: equal
    # init_tensor4 = [[[1/(poi_num * time_num) for i in range(poi_num)] for j in range(time_num)] for k in range(user_num)]