if __name__ == '__main__': time_slice = 4 train = 0.5 # beijing = (39.433333, 41.05, 115.416667, 117.5) # haidian = (39.883333, 40.15, 116.05, 116.383333) # region = (39.88, 40.03, 116.05, 116.25) # region = (39.88, 40.05, 116.05, 116.26) region = (39.88, 40.05, 116.05, 116.26) cluster_radius = 0.00 filter_count = 30 order = 2 top_k = 1 length, height, top_left = get_length_height(region) print "区域(长度,宽度):", length, height x_values = [] y_values1 = [] y_values2 = [] y_values3 = [] y_values4 = [] y_values5 = [] while cluster_radius <= 4.0: temp_data, time_slice, train, cluster_radius = init_data( time_slice, train, region, cluster_radius, filter_count) axis_pois, axis_users, train_structure_data, poi_adjacent_list, recommends, unknow_poi_set = preprocess( temp_data, time_slice, train, cluster_radius, order) print "train_structure_data: ", train_structure_data
# 2.Tersor Factorization(TF):基于用户-时间-地点的频数张量进行hosvd分解,没有用户的转移信息(地点对地点的评分) if __name__ == '__main__': time_slice = 2 train = 0.6 # beijing = (39.433333, 41.05, 115.416667, 117.5) # haidian = (39.883333, 40.15, 116.05, 116.383333) # region = (39.88, 40.03, 116.05, 116.25) # region = (39.88, 40.05, 116.05, 116.26) region = (39.88, 40.05, 116.05, 116.26) cluster_radius = 1 filter_count = 30 order = 2 top_k = 1 length, height, top_left = get_length_height(region) print "区域(长度,宽度):", length, height # pmpt temp_data, time_slice, train, cluster_radius = init_data(time_slice, train, region, cluster_radius, filter_count) axis_pois, axis_users, train_structure_data, poi_adjacent_list, recommends, unknow_poi_set = preprocess(temp_data, time_slice, train, cluster_radius, order) tensor = trans(train_structure_data, poi_adjacent_list, order, len(axis_pois), len(axis_users), time_slice) U, S, D = HOSVD(numpy.array(tensor), 0.7) A = reconstruct(S, U) # factorized markov chain temp_data2, time_slice, train2 = init_data2(region, train, time_slice, filter_count) axis_pois2, axis_users2, train_structure_data2, recommends2, unknow_poi_set2 = preprocess2(temp_data2, time_slice, train2, order) A2 = trans2(train_structure_data2, order, len(axis_pois2), time_slice, 0.7) # tensor factorization