예제 #1
0
def test_ltsa_eigendecomps():
    N = 10
    X, color = datasets.samples_generator.make_s_curve(N, random_state=0)
    n_components = 2
    G = geom.Geometry(adjacency_method = 'brute', adjacency_kwds = {'radius':2})
    G.set_data_matrix(X)
    mm_ltsa_ref, err_ref = ltsa.ltsa(G, n_components,
                                     eigen_solver=EIGEN_SOLVERS[0])
    for eigen_solver in EIGEN_SOLVERS[1:]:
        mm_ltsa, err = ltsa.ltsa(G, n_components, eigen_solver=eigen_solver)
        assert(_check_with_col_sign_flipping(mm_ltsa, mm_ltsa_ref, 0.05))
예제 #2
0
def test_ltsa_with_sklearn():
    N = 10
    X, color = datasets.samples_generator.make_s_curve(N, random_state=0)
    n_components = 2
    n_neighbors = 3
    knn = NearestNeighbors(n_neighbors + 1).fit(X)
    G = geom.Geometry()
    G.set_data_matrix(X)
    G.set_adjacency_matrix(knn.kneighbors_graph(X, mode = 'distance'))
    sk_Y_ltsa = manifold.LocallyLinearEmbedding(n_neighbors, n_components,
                                                method = 'ltsa',
                                                eigen_solver = 'arpack').fit_transform(X)
    (mm_Y_ltsa, err) = ltsa.ltsa(G, n_components, eigen_solver = 'arpack')
    assert(_check_with_col_sign_flipping(sk_Y_ltsa, mm_Y_ltsa, 0.05))