# create link inputs (link inputs used repeatedly but can have link input per group) # permute to bring diagonal to first position link_inputs = [[] for _ in range(output_dim)] for i in range(output_dim): idx = list(range(d_link.shape[0])) link_inputs[i] = d_link[[idx.pop(i)] + idx, :] link_inputs = link_inputs + [1.0 for i in range(output_dim) ] # for full W row blocks, independent nodes # create 'between' kernel list klink_rows = [ kernels.CompositeKernel('mul', [ kernels.RadialBasis( 2, std_dev=2.0, lengthscale=1.0, white=0.01, input_scaling=IS_ARD), kernels.CompactSlice( 2, active_dims=[0, 1], lengthscale=2.0, input_scaling=IS_ARD) ]) for i in range(output_dim) ] klink_f = [1.0 for i in range(node_dim)] kernlink = klink_rows + klink_f # create 'within' kernel # kern lag_active_dims_s = [[] for _ in range(output_dim)] for i in range(output_dim): lag_active_dims_s[i] = list(range(lag_dim * i, lag_dim * (i + 1))) k_rows = [ kernels.CompositeKernel('mul', [ kernels.RadialBasisSlice(lag_dim,
startsite = 0 # ignore for mtg # extract dataset d = get_inputs() Ytr, Yte, Xtr, Xte = d['Ytr'], d['Yte'], d['Xtr'], d['Xte'] Ytr, Yte = Ytr.reshape(Ytr.shape[0],1), Yte.reshape(Yte.shape[0],1) data = datasets.DataSet(Xtr.astype(np.float32), Ytr.astype(np.float32), shuffle=False) test = datasets.DataSet(Xte.astype(np.float32), Yte.astype(np.float32), shuffle=False) print("dataset created") klags = kernels.RadialBasisSlice(lag_dim, active_dims=[0,1], lengthscale=0.01, std_dev = 0.0, input_scaling = IS_ARD, white = 0.05) kspat = kernels.CompositeKernel('mul',[kernels.RadialBasisSlice(2, active_dims=[2,3], std_dev=2.0, lengthscale=0.5, white=0.05, input_scaling = IS_ARD), kernels.CompactSlice(2, active_dims=[2,3], lengthscale = 2.0, white = 0.05, input_scaling = IS_ARD)] ) ktime = kernels.PeriodicSliceFixed(1, active_dims=[Xtr.shape[1]-1], lengthscale=0.5, std_dev=1.5, period=144, white = 0.05) k_spattemp = kernels.CompositeKernel('mul', kernel_inputs=[kspat, ktime]) kern = [kernels.CompositeKernel('mul', kernel_inputs=[klags, k_spattemp])] likelihood = likelihoods.Gaussian(0.1) print("likelihood and kernels set") Z = init_z(data.X, NUM_INDUCING) m = mmgp.IndependentMMGP(output_dim, likelihood, kern, Z, num_components=NUM_COMPONENTS, diag_post=DIAG_POST, sparse_post=SPARSE_POST, num_samples=NUM_SAMPLES, predict_samples=PRED_SAMPLES) print("inducing points and model set")