Exemplo n.º 1
0
def test_pinv(A):
    pymf.pinv(A)
Exemplo n.º 2
0
    
    print desc + ': Fro.:', m.ferr[-1]/(A.shape[0] + A.shape[1]) , ' elapsed:' , time.time() - stime

    stime = time.time()
    m.factorize(show_progress=False, compute_h=False, niter=niter) 
    m.factorize(show_progress=False, compute_w=False, niter=niter)
    m.factorize(show_progress=False, compute_err=False, niter=niter)
    m.factorize(show_progress=True, niter=20)
    print desc + ' additional tests - elapsed:' , time.time() - stime
    
print "test all methods on boring random data..."
np.random.seed(400401) # VS for repeatability of experiments/tests
A = np.random.random((3,50)) + 2.0
B = scipy.sparse.csc_matrix(A)
# test pseudoinverse
pymf.pinv(A)
pymf.pinv(B)

m = test(A, pymf.SIVM_SEARCH, 'SIVM_SEARCH', 'c<', num_bases=2)
m = test(A, pymf.SIVM_GSAT, 'SIVM_GSAT ', 'c<', niter=20)
m = test(A, pymf.SIVM_SGREEDY, 'SIVM Greedy ', 'c<')
m = test(A, pymf.GMAP, 'GMAP ', 'c<')

svdm = test_svd(A, pymf.SVD, 'Singula Value Decomposition (SVD)', 'c<')
svdm = test_svd(A.T, pymf.SVD, 'Singula Value Decomposition (SVD)', 'c<')
svdm = test_svd(B, pymf.SVD, 'svd sparse', 'c<')
curm = test_svd(A, pymf.CUR, 'CUR Matrix Decomposition', 'b<')
curm = test_svd(B, pymf.CUR, 'CUR Matrix Decomposition (sparse data)', 'b<')
cmdm = test_svd(A, pymf.CMD, 'Compact Matrix Decomposition (CMD)', 'm<')
cmdm = test_svd(B, pymf.CMD, 'Compact Matrix Decomposition (CMD - sparse data)', 'm<')
sparse_svmcur = test_svd(A, pymf.SIVM_CUR, 'Simplex Volume Maximization f. CUR (SIVMCUR)', 'm<')
Exemplo n.º 3
0
             niterH=1,
             show_progress=False)
    m.initialization()
    m.factorize()

    print desc, m.ferr[-1] / (A.shape[0] +
                              A.shape[1]), ' elapsed:', time.time() - stime

    return m


print "test all methods on boring random data..."
A = np.round(np.random.random((2, 200))) + 2.0
B = scipy.sparse.csc_matrix(A)
# test pseudoinverse
pymf.pinv(A)
pymf.pinv(B)

svdm = test_svd(A, pymf.SVD, 'Singula Value Decomposition (SVD)', 'c<')
#svdm = test_svd(B, pymf.SVD, 'svd sparse', 'c<')
curm = test_svd(A, pymf.CUR, 'CUR Matrix Decomposition', 'b<')
curm = test_svd(B, pymf.CUR, 'CUR Matrix Decomposition (sparse data)', 'b<')
cmdm = test_svd(A, pymf.CMD, 'Compact Matrix Decomposition (CMD)', 'm<')
cmdm = test_svd(B, pymf.CMD,
                'Compact Matrix Decomposition (CMD - sparse data)', 'm<')
sparse_svmcur = test_svd(A, pymf.SIVMCUR,
                         'Simplex Volume Maximization f. CUR (SIVMCUR)', 'm<')
sparse_svmcur = test_svd(
    B, pymf.SIVMCUR,
    'Simplex Volume Maximization f. CUR (SIVMCUR - sparse data)', 'm<')
m = test(A, pymf.PCA, 'Principal Component Analysis (PCA)', 'c<')
Exemplo n.º 4
0
def test_pinv(A):
    pymf.pinv(A)