def _predict_pset(self, pset, theta): i,j = pset X = self.X.loc[:,[j]+i].values Y = self.Y.loc[:,[j]].values return gp.rbf(X,Y,theta).predict(X)
def eval_gp(self, i, theta): "Evaluate a GP for parental set @i using a RBF" # extract the items for our given parental set pi,gi = self.pset[i] # pull out data for these items X = self.X.loc[:,[gi]+pi].values Y = self.Y.loc[:,[gi]].values # evaluate the GP return gp.rbf(X, Y, theta)
def __init__(self, res, pset, datasets=None): self.target = res.target self.hypers = res.hypers self.pset = list(pset) self.ix = [self.target]+self.pset self.iy = [self.target] if datasets is None: datasets = (r.data for r in res.mod.reps) X = [] # parent array Y = [] # target array for d in datasets: X.append(d[self.ix,:-1]) Y.append(d[self.iy,1:]) X = np.hstack(X).T Y = np.hstack(Y).T self.gp = gp.rbf(X,Y,self.hypers)