Ejemplo n.º 1
0
 def fit(self, XTrain=None, yTrain=None, KTrain=None, delta=None, folds=0):
     self.nTrain = yTrain.shape[0]
     self.yTrain = yTrain
     if KTrain is not None:
         self.kernel = KTrain
     self.S, self.U = LA.eigh(self.kernel + SP.eye(self.nTrain) * 1e-8)
     self.Uy = SP.dot(self.U.T, yTrain)
     self.Uone = SP.dot(self.U.T, SP.ones_like(yTrain))
     if delta is None:
         # Initialize cross-learning of delta
         if folds > 0:
             self.ldelta = self.crossvalidate_delta(folds)
         else:
             self.ldelta = dlimix.optdelta(self.Uy[:, 0], self.Uone, self.S,
                                           100000, -5.0, 5.0)
         self.delta = SP.exp(self.ldelta)
     else:
         self.delta = delta
         self.ldelta = SP.log(delta)
     self.cov = LA.inv((self.kernel + SP.eye(self.nTrain) * self.delta))
Ejemplo n.º 2
0
 def fit(self, XTrain=None, yTrain=None, KTrain=None, delta=None, folds=0):
     self.nTrain = yTrain.shape[0]
     self.yTrain = yTrain
     if KTrain is not None:
         self.kernel = KTrain
     self.S, self.U = LA.eigh(self.kernel+SP.eye(self.nTrain)*1e-8)
     self.Uy = SP.dot(self.U.T, yTrain)
     self.Uone = SP.dot(self.U.T, SP.ones_like(yTrain))
     if delta is None:
         # Initialize cross-learning of delta
         if folds > 0:
             self.ldelta = self.crossvalidate_delta(folds)
         else:
             self.ldelta = dlimix.optdelta(self.Uy[:, 0], self.Uone, self.S,
                                          100000, -5.0, 5.0)
         self.delta = SP.exp(self.ldelta)
     else:
         self.delta = delta
         self.ldelta = SP.log(delta)
     self.cov = LA.inv((self.kernel + SP.eye(self.nTrain)*self.delta))
Ejemplo n.º 3
0
 def update_delta(self, mean):
     Umean = SP.dot(self.U.T, mean)
     self.ldelta = dlimix.optdelta(self.Uy[:, 0], Umean, self.S, 100,
                                   self.ldelta - 1., self.delta + 1.)
     self.delta = SP.exp(self.ldelta)
     return self.delta
Ejemplo n.º 4
0
 def update_delta(self, mean):
     Umean = SP.dot(self.U.T, mean)
     self.ldelta = dlimix.optdelta(self.Uy[:, 0], Umean, self.S, 100,
                                  self.ldelta-1., self.delta+1.)
     self.delta = SP.exp(self.ldelta)
     return self.delta