Exemple #1
0
    def test_pinv(self):
        test_cases = self.pinv_test_cases

        for in_mat, expected_out in test_cases:
            out_mat = Linalg.pinv(DenseMatrix(in_mat))
            np.testing.assert_array_almost_equal(out_mat.mat, expected_out, 7)

            out_mat = Linalg.pinv(SparseMatrix(in_mat))
            np.testing.assert_array_almost_equal(out_mat.mat.todense(),
                                                 expected_out, 7)
Exemple #2
0
    def test_pinv(self):
        test_cases = self.pinv_test_cases

        for in_mat, expected_out in test_cases:
            out_mat = Linalg.pinv(DenseMatrix(in_mat))
            np.testing.assert_array_almost_equal(out_mat.mat, expected_out, 7)

            out_mat = Linalg.pinv(SparseMatrix(in_mat))
            np.testing.assert_array_almost_equal(out_mat.mat.todense(),
                                                 expected_out, 7)
Exemple #3
0
 def apply(self, matrix_):    
     
     matrix_.assert_positive()
     #w_init, h_init = self.nndsvd_init(matrix_)
     w_init, h_init = self.v_col_init(matrix_)
     #w_init, h_init = self.random_init(matrix_)
     w, h = Linalg.nmf(matrix_, w_init, h_init)
     return w, Linalg.pinv(h)
Exemple #4
0
    def apply(self, matrix_):

        matrix_.assert_positive()
        #w_init, h_init = self.nndsvd_init(matrix_)
        w_init, h_init = self.v_col_init(matrix_)
        #w_init, h_init = self.random_init(matrix_)
        w, h = Linalg.nmf(matrix_, w_init, h_init)
        return w, Linalg.pinv(h)