Exemplo n.º 1
0
 def _compute_w_row(self, Xw, w, W, idx):
     g, gd = self._exp(Xw.multiply(DenseMatrix(len(w), 1, w)))
     w_new = column_means(elementwise_product(Xw, g, self.spark))
     del g
     w_new = w_new - gd * w
     w_new = gs_decorrelate(w_new, W, idx)
     w_new /= scipy.sqrt((w_new**2).sum())
     return w_new
Exemplo n.º 2
0
 def _preprocess_data(self, data):
     X = self._feature_matrix(data)
     self.__means = column_means(X)
     return RowMatrix(center(X, means=self.__means))
Exemplo n.º 3
0
 def _exp(X):
     g = X.rows.map(lambda x: x * scipy.exp(-(scipy.power(x, 2.0)) / 2.0))
     g_ = X.rows.map(lambda x: (1 - scipy.power(x, 2.0)) * scipy.exp(-(
         scipy.power(x, 2.0)) / 2.0))
     gm = column_means(g_).mean()
     return RowMatrix(g), gm