# data file index = 0 # sys.argv[1] rat = datafiles[int(index)] print rat f = '/tigress/fdamani/neuro_data/data/raw/allrats_withmissing_limitedtrials/csv/' f += rat rat = f.split('/')[-1].split('.csv')[0] # add to dir name savedir += '__obs' + str(num_obs_samples) savedir += '__' + rat # os.mkdir(savedir) # f = '../data/W066_short.csv' x, y, rw = read_and_process(num_obs_samples, f, savedir=savedir) rw = torch.tensor(rw, dtype=dtype, device=device) dim = x.shape[2] T = x.shape[0] init_prior = ([0.0] * dim, [math.log(1.0)] * dim) transition_scale = [math.log(1.0)] #* dim num_future_steps = 1 category_tt_split = 'single' num_mc_samples = 10 y, x, y_future, x_future = train_future_split(y, x, num_future_steps) y_train, y_test, test_inds = train_test_split(y, x, cat=category_tt_split) x = torch.tensor(x, dtype=dtype, device=device) y_train = torch.tensor(y_train, dtype=dtype, device=device) y_test = torch.tensor(y_test, dtype=dtype, device=device) test_inds = torch.tensor(test_inds, dtype=torch.long, device=device)
os.makedirs(output_file + '/plots') savedir = output_file raw_datasets = [] for ind in inds: index = ind rat = datafiles[int(index)] print rat if torch.cuda.is_available(): f = '/tigress/fdamani/neuro_data/data/raw/allrats_withmissing_limitedtrials/csv/' else: f = '../data/' f += rat rat = f.split('/')[-1].split('.csv')[0] x, y, rw = read_and_process(num_obs_samples, f, savedir=savedir, proficient=False) # x = x[0:500] # y = y[0:500] # rw = rw[0:500] rw = torch.tensor(rw, dtype=dtype, device=device) z_true = None true_model_params = None dim = x.shape[2] T = x.shape[0] raw_datasets.append((x, y, rw, z_true, true_model_params, dim, T, rat)) datasets = [] for dataset in raw_datasets: x, y, rw, z_true, true_model_params, dim, T, rat = dataset
# rat = f.split('/')[-1].split('.csv')[0] # num_obs_samples=1 #output_file += '/'+rat output_file += '/kfold_single_alpha_results_2k' os.makedirs(output_file) folds = np.arange(1, len(datafiles)) held_out_marginal_lhs = [] for fd in folds: rat = datafiles[fd] f = '/tigress/fdamani/neuro_data/data/raw/allrats_withmissing_limitedtrials/csv/' #f = '../data/' #rat = 'W073.csv' f += rat num_obs_samples = 1 x, y, rw = read_and_process(num_obs_samples, f, savedir=output_file) T = 2000 #T = 50 #num_particles = 100 num_particles = 1000 x = x[0:T] y = y[0:T] x = torch.tensor(x, dtype=dtype, device=device) y = torch.tensor(y, dtype=dtype, device=device) dim = x.shape[-1] md = LearningDynamicsModel(dim) ev = HeldOutRat([y, x], md) model_params_file = '/tigress/fdamani/neuro_output/5.5/single_alpha_shared_model_kfold_leave_out_' + str(