Exemplo n.º 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))
Exemplo n.º 2
0
def test_mds():
    """
    Test of the multi-dimensional scaling algorithm
    """
    X = randn(10,3)
    M = MDS(X, rdim=2)
    u = M.train()
    x = X[:2]
    a = M.test(x)
    eps = 1.e-12
    test = np.sum(a-u[:2])**2<eps
    assert test