def compute(kernel_name, x, y):
    if kernel_name == 'hik':
        return kernels.histogram_intersection(x, y)
    elif kernel_name == 'linear':
        return kernels.linear(x, y)
    elif kernel_name == 'chi2':
        return kernels.chi_square(x, y)
    else:
        raise ValueError(kernel_name)
示例#2
0
    def __init__(self, Y, dim, nparticles=100):
        self.Xdim = dim
        self.T, self.Ydim = Y.shape
        """Use PCA to initalise the problem. Uses EM version in this case..."""
        myPCA_EM = PCA_EM(Y, dim)
        myPCA_EM.learn(300)
        X = np.array(myPCA_EM.m_Z)

        self.observation_GP = GP.GP(X, Y)

        #create a linear kernel for the dynamics
        k = kernels.linear(-1, -1)
        self.dynamic_GP = GP.GP(X[:-1], X[1:], k)

        #initialise the samples from the state /latent variables
        self.particles = np.zeros((self.T, nparticles, self.Xdim))

        #sample for x0 TODO: variable priors on X0
        self.particles[0, :, :] = np.random.randn(nparticles, self.Xdim)
示例#3
0
	def __init__(self,Y,dim,nparticles=100):
		self.Xdim = dim
		self.T,self.Ydim = Y.shape
		
		"""Use PCA to initalise the problem. Uses EM version in this case..."""
		myPCA_EM = PCA_EM(Y,dim)
		myPCA_EM.learn(300)
		X = np.array(myPCA_EM.m_Z)
		
		self.observation_GP = GP.GP(X,Y)
		
		#create a linear kernel for the dynamics
		k = kernels.linear(-1,-1)
		self.dynamic_GP = GP.GP(X[:-1],X[1:],k)
		
		#initialise the samples from the state /latent variables
		self.particles = np.zeros((self.T,nparticles,self.Xdim))
		
		#sample for x0 TODO: variable priors on X0
		self.particles[0,:,:] = np.random.randn(nparticles,self.Xdim)
示例#4
0
args = parser.parse_args()

if args.dataset == "himoon":
    x, y, _, _, xtest, ytest = data_gen.himoon(n_samples=args.n_samples,
                                               n_dims=args.n_dims)

elif args.dataset == "mmgauss":
    x, y, _, _, xtest, ytest = data_gen.mmgauss(n_samples=args.n_samples,
                                                n_dims=args.n_dims)
else:
    raise ValueError("Unknown dataset")

kernels = dict(
    zip(
        ["rbf", "linear", "poly", "sigmoid"],
        [k.rbf(), k.linear(), k.poly(),
         k.sigmoid()],
    ))
try:
    kernel = kernels.get(args.kernel)
except KeyError as e:
    kernel = "linear"

df = pd.DataFrame()

print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}: Running " +
      f"{args.dataset} with {args.dimension} dimensions and " +
      f"epsilon={args.epsilon} with {args.kernel} kernel for " +
      f"{args.repetitions} repetitions.")

for run in range(args.repetitions):