def single_run(city, cicnt=20, wl=100, wt=20, n_feature=128, new_run=False): # city = "Brightkite"# ny la london Gowalla Brightkite # cicnt = 20 folder_setup(city) checkin, friends = data_process(city, cicnt) ul_graph, lu_graph = ul_graph_build(checkin, 'locid') model_name = str(cicnt) + '_locid' print(model_name) walk_len, walk_times = 100, 20 # maximal 100 walk_len, 20 walk_times print('walking') if new_run: para_ul_random_batch(city, model_name, checkin.uid.unique(), ul_graph, lu_graph, walk_len, walk_times) print('walk done') print('emb training') emb_train(city, model_name, wl, wt, n_feature) print('emb training done') feature_construct(city, model_name, friends, wl, wt, n_feature) unsuper_friends_predict(city, model_name, wl, wt, n_feature)
def single_run(city, cicnt, ratio): # ratio = int(sys.argv[3])# 10 20 30 40 ratio = ratio * 1.0 / 100 folder_setup(city) checkin, friends = data_process(city, cicnt) defense_name = str(cicnt) + '_hiding_' + str(int(ratio * 100)) print(defense_name) checkin = para_hiding(city, defense_name, checkin, ratio) ul_graph, lu_graph = ul_graph_build(checkin, 'locid') model_name = str(cicnt) + '_locid_hiding_' + str(int(ratio * 100)) print(model_name) walk_len, walk_times = 100, 20 # maximal 100 walk_len, 20 walk_times print('walking') para_ul_random_walk(city, model_name, checkin.uid.unique(), ul_graph, lu_graph, walk_len, walk_times) print('walk done') print('emb training') emb_train(city, model_name) print('emb training done') feature_construct(city, model_name, friends) unsuper_friends_predict(city, model_name)
def single_ex_run(city, cicnt): folder_setup(city) checkin, friends = data_process(city, cicnt) defense_name = str(cicnt) + '_ex' print(defense_name) checkin = extreme_balance(city, defense_name, checkin) ul_graph, lu_graph = ul_graph_build(checkin, 'locid') model_name = str(cicnt) + '_locid_ex' print(model_name) walk_len, walk_times = 100, 20 # maximal 100 walk_len, 20 walk_times print('walking') para_ul_random_batch(city, model_name, checkin.uid.unique(), ul_graph, lu_graph, walk_len, walk_times) print('walk done') print('emb training') emb_train(city, model_name) print('emb training done') feature_construct(city, model_name, friends) unsuper_friends_predict(city, model_name)
def batch_random_walk(num_user, num_location): city = 'workload_' + str(num_user) + '_' + str(num_location) folder_setup(city) cicnt = 20 checkin, friends = data_process(city, cicnt) ul_graph, lu_graph = ul_graph_build(checkin, 'locid') model_name = str(cicnt) + '_locid' print(model_name) walk_len, walk_times = 50, 10 # maximal 100 walk_len, 20 walk_times print('walking') para_ul_random_batch(city, model_name, checkin.uid.unique(), ul_graph, lu_graph, walk_len, walk_times) print('walk done')
def single_replace(city, cicnt, ratio, step, fail_to_continue=False): ratio = ratio * 1.0 / 100 folder_setup(city) checkin, friends = data_process(city, cicnt) defense_name = str(cicnt) + '_replace_' + str(int( ratio * 100)) + '_' + str(int(step)) model_name = str(cicnt) + '_locid_replace_' + str(int( ratio * 100)) + '_' + str(int(step)) if not fail_to_continue: checkin = para_replace(city, defense_name, checkin, ratio, step) else: checkin = pd.read_csv('dataset/'+ city + '/defense/' + city + \ '_20_replace_'+ str(int(ratio * 100)) + '_' + str(int(step)) + '.checkin') ul_graph, lu_graph = ul_graph_build(checkin, 'locid') walk_len, walk_times = 100, 20 # maximal 100 walk_len, 20 walk_times print('walking') if not fail_to_continue: para_ul_random_batch(city, model_name, checkin.uid.unique(), ul_graph, lu_graph, walk_len, walk_times) print('walk done') print('emb training') emb_train(city, model_name) print('emb training done') feature_construct(city, model_name, friends) unsuper_friends_predict(city, model_name)
import sys from process import folder_setup, data_process from defense import para_replace from emb import ul_graph_build, para_ul_random_walk, emb_train from predict import feature_construct, unsuper_friends_predict city = sys.argv[1] cicnt = int(sys.argv[2]) ratio = int(sys.argv[3]) # 10 20 30 40 ratio = ratio * 1.0 / 100 step = int(sys.argv[4]) folder_setup(city) checkin, friends = data_process(city, cicnt) defense_name = str(cicnt) + '_replace_' + str(int(ratio * 100)) + '_' + str( int(step)) checkin = para_replace(city, defense_name, checkin, ratio, step) ul_graph, lu_graph = ul_graph_build(checkin, 'locid') model_name = str(cicnt) + '_locid_replace_' + str(int( ratio * 100)) + '_' + str(int(step)) walk_len, walk_times = 100, 20 # maximal 100 walk_len, 20 walk_times print 'walking' para_ul_random_walk(city, model_name, checkin.uid.unique(), ul_graph, lu_graph,\ walk_len, walk_times)
import sys from process import data_process from utility import js_utility city = sys.argv[1] cicnt = int(sys.argv[2]) ratio = int(sys.argv[3]) # 10 20 30 40 ratio = ratio * 1.0 / 100 step = int(sys.argv[4]) checkin, _ = data_process(city, cicnt) defense_name = str(cicnt) + '_replace_' + str(int(ratio * 100)) + '_' + str( int(step)) js_utility(city, defense_name, checkin)
# classifier_hidden_layers = '' # else: # classifier_hidden_layers = [int(i) for i in (args.classifier_hidden_layers).split(',')] # dropout = args.dropout # building_weight = args.building_weight # floor_weight = args.floor_weight # N = args.neighbours # scaling = args.scaling os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" # see issue #152 if gpu_id >= 0: os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu_id) else: os.environ["CUDA_VISIBLE_DEVICES"] = '' os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' [x_trainval, y_trainval, x_train, y_train, x_val, y_val, x_test, y_test, dataset_name] = data_process() OUTPUT_DIM = y_train.shape[1] INPUT_DIM = x_train.shape[1] # pd.DataFrame(x_train).to_csv('preprocessed_data//' + 'train' + '_' + '.csv') # pd.DataFrame(x_val).to_csv('preprocessed_data//' + 'val' + '_' + '.csv') # pd.DataFrame(x_test).to_csv('preprocessed_data//' + 'test' + '_' + '.csv') for dropout in [0.1]: #for LR_REDUCE_FACTOR in [0.05, 0.1, 0.5, 0.9]: for LR_REDUCE_FACTOR in [1]: hr_ls = [] for SIZE in range(6, 23, 2): root_folder = 'd' + str(dropout) + 'f' + str(LR_REDUCE_FACTOR) + '//' + str( SIZE) + 'x' + str(SIZE) # true_index = [] # false_index = []