def test_GPC_FITC(self): print("testing GP sparse classification...") model = pyGPs.GPC_FITC() m = pyGPs.mean.Zero() k = pyGPs.cov.RBF() model.setPrior(mean=m, kernel=k, inducing_points=self.uc) model.setOptimizer("Minimize", num_restarts=10) model.optimize(self.xc, self.yc) model.predict(self.zc) self.checkClassificationOutput(model) model = pyGPs.GPC_FITC() m = pyGPs.mean.Zero() k = pyGPs.cov.RBF() model.setPrior(mean=m, kernel=k, inducing_points=self.uc) model.setOptimizer("Minimize", num_restarts=10) model.useInference("Laplace") model.optimize(self.xc, self.yc) model.predict(self.zc) self.checkClassificationOutput(model)
# only needed for 2-d contour plotting x1 = demoData['x1'] # x for class 1 (with label -1) x2 = demoData['x2'] # x for class 2 (with label +1) t1 = demoData['t1'] # y for class 1 (with label -1) t2 = demoData['t2'] # y for class 2 (with label +1) p1 = demoData['p1'] # prior for class 1 (with label -1) p2 = demoData['p2'] # prior for class 2 (with label +1) #---------------------------------------------------------------------- # Sparse GP classification (FITC) example #---------------------------------------------------------------------- print "Example 1: default inducing points" # Start from a new model model = pyGPs.GPC_FITC() # Notice if you want to use default inducing points: # You MUST call setData(x,y) FIRST! # The default inducing points is a grid(hypercube in higher dimension), where # each dimension has 5 values in same step between min and max value of data by default. model.setData(x, y) # To set value per dimension use: # model.setData(x, y, value_per_axis=10) model.optimize() print "Negative log marginal liklihood optimized:", round(model.nlZ, 3) # Prediction n = z.shape[0]