#data_type = 'random' #full_data,Z_gen = generate_data(feature_count,data_count + held_out,T,sig,data_type) #Y = full_data[:data_count,:] #held_out = full_data[data_count:,:] iterate = 5000 small_x = 3 small_y = 3 big_x = 3 big_y = 3 data_dim = (small_x,small_y,big_x,big_y) feature_count = big_x*big_y T = small_x*small_y*big_x*big_y data_type = 'corr' flag = 'nine' #full_data,Z_gen = generate_data(feature_count,data_count + held_out,T,sig,data_type) full_data,Z_gen = construct_data(small_x,small_y,big_x,big_y,data_count + held_out,sig,data_type,corr_value=2) Y = full_data[:data_count,:] held_out = full_data[data_count:,:] K = 1 #start with K features ext = 1 #draw one new feature per iteration # profile.run('ugibbs_sample(log_res,hold,Y,ext,sig,sig_w,iterate,K,valid)') runs = 1 ll_data = np.zeros((runs,iterate)) ll_time = np.zeros((runs,iterate)) feature = np.zeros((runs,iterate)) lapse_data = np.zeros((runs,iterate)) #pred_data = np.zeros((runs,iterate)) valid = 0
sig_test = sig small_x = 3 small_y = 3 big_x = 2 big_y = 2 data_dim = (small_x, small_y, big_x, big_y) feature_count = big_x * big_y T = small_x * small_y * big_x * big_y #data_type = 'random' #data_type = 'special' #data_type = 'random' #data_type = 'debug' data_type = 'debug-four' flag = 'four' #full_data,Z_gen = generate_data(feature_count,data_count + held_out,T,sig,data_type) full_data, Z_gen = construct_data(data_dim, data_count + held_out, sig, data_type) Y = full_data[:data_count, :] held_out = full_data[data_count:, :] #we observe half the signal and recover the other half observe = held_out[:, :T / 2] trunc = 12 #truncate active features if algorithm == 'IBP': iterate = 200 alpha = 2.0 select = 12 Z, W, ll_set, pred_ll = ugibbs_sampler(Y, held_out, alpha, sig_test, sig_w, iterate, select, trunc, data_dim) Z_trunc, W_trunc = truncate(Z, W, select) print_posterior(Z_trunc, W_trunc, data_dim) recover_ll = recover_IBP(held_out, observe, Z, W, sig_test)
held_out = 50 sig = 0.1 #noise sig_w = 0.2 #feature deviation small_x = 3 small_y = 3 big_x = 3 big_y = 3 data_dim = (small_x, small_y, big_x, big_y) feature_count = big_x * big_y T = small_x * small_y * big_x * big_y select = 12 data_type = 'corr' #full_data,Z_gen = generate_data(feature_count,data_count + held_out,T,sig,data_type) full_data, Z_gen = construct_data(data_dim, data_count + held_out, sig, data_type, corr_value=2) Y = full_data[:data_count, :] held_out = full_data[data_count:, :] Z, W, ll_set, pred_ll = ugibbs_sampler(Y, held_out, alpha, sig, sig_w, iterate, select) approx = np.dot(Z, W) for i in range(10): print("sample: " + str(i)) print("features probability") #print(prob_matrix[i,:]) print("features selected") print(Z[i, :])