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)