Exemplo n.º 1
0
 def method_instance(self):
     if not hasattr(self, "_method_instance"):
         n, p = self.X.shape
         self._method_instance = randomized_modelQ(self.feature_cov * n,
                                                   self.X,
                                                   self.Y,
                                                   self.lagrange * np.sqrt(n),
                                                   randomizer_scale=self.randomizer_scale * np.std(self.Y) * np.sqrt(n))
     return self._method_instance
Exemplo n.º 2
0
    def method_instance(self):
        if not hasattr(self, "_method_instance"):

            # draw sample of X for semi-supervised method
            _chol = self._chol
            p = _chol.shape[0]
            Q = 0
            batch_size = int(self.B/10)
            for _ in range(10):
                X_semi = np.random.standard_normal((batch_size, p)).dot(_chol.T)
                Q += X_semi.T.dot(X_semi)
            Q += self.X.T.dot(self.X)
            Q /= (10 * batch_size + self.X.shape[0])

            n, p = self.X.shape
            self._method_instance = randomized_modelQ(Q * n,
                                                      self.X,
                                                      self.Y,
                                                      self.lagrange * np.sqrt(n),
                                                      randomizer_scale=self.randomizer_scale * np.std(self.Y) * np.sqrt(n))
        return self._method_instance