Пример #1
0
def test_pca_and_mds():
    """
    """
    X = randn(10,3)
    M = MDS(X, rdim=2)
    u1 = M.train()
    P = PCA(X,rdim=2)
    u2 = P.train()
    eta = np.dot(u1.T,u2)
    delta = eta - np.diag(np.diag(eta))
    print delta, eta
    assert (np.sum(delta**2)<1.e-12*np.sum(eta**2))
Пример #2
0
def test_pca():
    """
    Test of the multi-dimensional scaling algorithm
    """
    X = randn(10,3)
    P = PCA(X, rdim=2)
    u = P.train()
    x = X[:2]
    a = P.test(x)
    eps = 1.e-12
    test = np.sum(a-u[:2])**2<eps
    print a, u[:2]
    assert test