コード例 #1
0
 def test_compute_w(self):
     """ Computing W without computing H doesn't make much sense for chnmf..
     """
     mdl = CHNMF(self.data, num_bases=3)
     mdl.H = self.H
     mdl.factorize(niter=10, compute_h=False)
     assert_set_equal(mdl.W, self.W, decimal=2)
コード例 #2
0
ファイル: test_bnmf.py プロジェクト: enamoria/exemplars_vc
    def test_cnmf(self):
        mdl = BNMF(self.data, num_bases=2)

        mdl.factorize(niter=100)
        assert_set_equal(mdl.W, self.W, decimal=1)

        assert_set_equal(mdl.H.T, self.H, decimal=1)
        rec = mdl.frobenius_norm()
        assert(rec <= 0.1)
コード例 #3
0
ファイル: test_nmf.py プロジェクト: enamoria/exemplars_vc
    def test_rnmf(self):
        mdl = RNMF(self.data, num_bases=2)

        # nmf forms a cone in the input space, but it is unlikely to hit the
        # cone exactly.
        mdl.factorize(niter=50)
        assert_set_equal(mdl.W.T / np.sum(mdl.W, axis=1), self.W, decimal=1)

        # the reconstruction quality should still be close to perfect
        rec = mdl.frobenius_norm()
        assert_almost_equal(0.0, rec, decimal=1)
コード例 #4
0
ファイル: test_nmf.py プロジェクト: enamoria/exemplars_vc
    def test_nmf(self):
        mdl = NMF(self.data, num_bases=2)

        # nmf forms a cone in the input space, but it is unlikely to hit the
        # cone exactly.
        mdl.factorize(niter=50)
        assert_set_equal(mdl.W, self.W, decimal=1)

        # since the basis vector will be close to 1/0, the coefficients should
        # converge to the original data.
        assert_set_equal(mdl.H.T, self.data.T, decimal=1)

        # the reconstruction quality should still be close to perfect
        rec = mdl.frobenius_norm()
        assert_almost_equal(0.0, rec, decimal=1)
コード例 #5
0
ファイル: test_cnmf.py プロジェクト: enamoria/exemplars_vc
    def test_cnmf(self):
        mdl = CNMF(self.data, num_bases=2)

        # nmf forms a cone in the input space, but it is unlikely to hit the
        # cone exactly.
        mdl.factorize(niter=100)
        W = mdl.W/np.sum(mdl.W, axis=0)
        assert_set_equal(W, self.W, decimal=1)

        # since the basis vector will be close to 1/0, the coefficients should
        # converge to the original data.
        H = mdl.H/np.sum(mdl.H, axis=0)
        assert_set_equal(H.T, self.H, decimal=1)

        # the reconstruction quality should still be close to perfect
        rec = mdl.frobenius_norm()
        assert(rec <= 0.1)
コード例 #6
0
 def test_compute_h(self):
     mdl = CHNMF(self.data, num_bases=3)
     mdl.W = self.W
     mdl.factorize(niter=10, compute_w=False)
     assert_set_equal(mdl.H, self.H, decimal=2)
コード例 #7
0
ファイル: test_sivm.py プロジェクト: enamoria/exemplars_vc
 def test_compute_w(self):
     mdl = SIVM(self.data, num_bases=3)
     mdl.H = self.H
     mdl.factorize(niter=10, compute_h=False)
     assert_set_equal(mdl.W, self.W, decimal=2)