edge_weight=true_adj[np.triu_indices(user_num,1)] edge_color=edge_weight[edge_weight>0] #pos = nx.spring_layout(graph) plt.figure(figsize=(5,5)) nodes=nx.draw_networkx_nodes(graph, pos, node_size=10, node_color='y') edges=nx.draw_networkx_edges(graph, pos, width=0.05, alpha=1, edge_color='k') edge_labels=nx.draw_networkx_edge_labels(graph,pos, edge_labels=labels, font_size=5) plt.axis('off') plt.savefig(path+'network_rbf_thres_%s_edge_num_%s'%(int(thres*10), edge_num)+'.png', dpi=300) plt.savefig(path+'network_rbf_thres_%s_edge_num_%s'%(int(thres*10), edge_num)+'.eps', dpi=300) for l in range(loop): print('loop/total_loop', l, loop) linucb_model=LINUCB(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs, alpha, delta, sigma, state) gob_model=GOB(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs, true_adj, alpha, delta, sigma, beta, state) lapucb_model=LAPUCB(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs, true_adj, noise_matrix, alpha, delta, sigma, beta, thres, state) lapucb_sim_model=LAPUCB_SIM(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs, true_adj, noise_matrix, alpha, delta, sigma, beta, thres, state) club_model = CLUB(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs, alpha, alpha_2, delta, sigma, beta, state) linucb_regret, linucb_error, linucb_beta=linucb_model.run(user_seq, item_pool_seq, iteration) gob_regret, gob_error, gob_beta, gob_graph=gob_model.run(user_seq, item_pool_seq, iteration) lapucb_regret, lapucb_error, lapucb_beta, lapucb_graph=lapucb_model.run(user_seq, item_pool_seq, iteration) lapucb_sim_regret, lapucb_sim_error, lapucb_sim_beta, lapucb_sim_graph=lapucb_sim_model.run( user_seq, item_pool_seq, iteration) club_regret, club_error,club_cluster_num, club_beta=club_model.run(user_seq, item_pool_seq, iteration) linucb_regret_matrix[l], linucb_error_matrix[l]=linucb_regret, linucb_error gob_regret_matrix[l], gob_error_matrix[l], gob_graph_matrix[l]=gob_regret, gob_error, gob_graph lapucb_regret_matrix[l], lapucb_error_matrix[l], lapucb_graph_matrix[l]=lapucb_regret, lapucb_error, lapucb_graph lapucb_sim_regret_matrix[l], lapucb_sim_error_matrix[l], lapucb_sim_graph_matrix[l]=lapucb_sim_regret, lapucb_sim_error, lapucb_sim_graph club_regret_matrix[l], club_error_matrix[l]=club_regret, club_error
gob_error_matrix_beta = np.zeros((beta_length, iteration)) for index, b in enumerate(beta_list): linucb_regret_matrix = np.zeros((loop, iteration)) linucb_error_matrix = np.zeros((loop, iteration)) gob_regret_matrix = np.zeros((loop, iteration)) gob_error_matrix = np.zeros((loop, iteration)) for l in range(loop): print('loop/total_loop', l, loop) linucb_model = LINUCB(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs, 0.25, delta, sigma, state) gob_model = GOB(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs, true_adj, true_lap, 0.25, delta, sigma, b, state) linucb_regret, linucb_error, linucb_beta, linucb_x_norm, linucb_inst_regret, linucb_ucb, linucb_sum_x_norm, linucb_real_beta = linucb_model.run( user_seq, item_pool_seq, iteration) gob_regret, gob_error, gob_beta, gob_x_norm, gob_ucb, gob_sum_x_norm, gob_real_beta = gob_model.run( user_seq, item_pool_seq, iteration) linucb_regret_matrix[l], linucb_error_matrix[ l] = linucb_regret, linucb_error gob_regret_matrix[l], gob_error_matrix[l] = gob_regret, gob_error linucb_regret = np.mean(linucb_regret_matrix, axis=0) linucb_error = np.mean(linucb_error_matrix, axis=0) gob_regret = np.mean(gob_regret_matrix, axis=0) gob_error = np.mean(gob_error_matrix, axis=0)
true_adj[true_adj<=thres]=0.0 true_normed_adj=true_adj/true_adj.sum(axis=0,keepdims=1) true_lap=csgraph.laplacian(true_adj) true_adj_binary=true_adj.copy() true_adj_binary[true_adj_binary>0]=1 true_lap_binary=np.diag(np.sum(true_adj_binary, axis=1))-true_adj_binary lap=np.identity(user_num) normed_lap=lap noise_matrix=np.zeros((user_num, item_num)) user_seq=np.random.choice(range(user_num), size=iteration) item_pool_seq=np.random.choice(range(item_num), size=(iteration, pool_size)) linucb_model=LINUCB(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs, alpha, delta, sigma) gob_model=GOB(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs, true_lap_binary, alpha, delta, sigma, beta) colin_model=COLIN(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs, true_normed_adj, alpha, delta, sigma, beta) lapucb_model=LAPUCB(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs, noise_matrix, normed_lap, alpha, delta, sigma) lapucb_sim_model=LAPUCB_SIM(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs, noise_matrix, normed_lap, alpha, delta, sigma) club_model = CLUB(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs,normed_lap, alpha, alpha_2, delta, sigma, beta) sclub_model = SCLUB(dimension, user_num, item_num, pool_size, item_feature_matrix, user_feature_matrix, true_payoffs,normed_lap, alpha, delta, sigma, beta) linucb_regret, linucb_error, linucb_beta=linucb_model.run(user_seq, item_pool_seq, iteration) gob_regret, gob_error, gob_beta=gob_model.run(user_seq, item_pool_seq, iteration) colin_regret, colin_error, colin_beta=colin_model.run(user_seq, item_pool_seq, iteration) lapucb_regret, lapucb_error, lapucb_beta=lapucb_model.run(user_seq, item_pool_seq, iteration) lapucb_sim_regret, lapucb_sim_error, lapucb_sim_beta=lapucb_sim_model.run(user_seq, item_pool_seq, iteration) club_regret, club_error,club_graph_error, club_cluster_num, club_beta=club_model.run(user_seq, item_pool_seq, iteration) sclub_regret, sclub_error,sclub_graph_error, sclub_cluster_num, sclub_beta=sclub_model.run(user_seq, item_pool_seq, iteration)