diff --git a/sklearn/manifold/tests/test_isomap.py b/sklearn/manifold/tests/test_isomap.py index 7afd66469998e141e83584f24dcd4eb25ac6441e..2b72e1bfac08307cc603d5e3df9d95ce0639b357 100644 --- a/sklearn/manifold/tests/test_isomap.py +++ b/sklearn/manifold/tests/test_isomap.py @@ -111,12 +111,14 @@ def test_transform(): def test_pipeline(): # check that Isomap works fine as a transformer in a Pipeline - iris = datasets.load_iris() + # only checks that no error is raised. + # TODO check that it actually does something useful + X, y = datasets.make_blobs(random_state=0) clf = pipeline.Pipeline( [('isomap', manifold.Isomap()), - ('neighbors_clf', neighbors.KNeighborsClassifier())]) - clf.fit(iris.data, iris.target) - assert_lower(.7, clf.score(iris.data, iris.target)) + ('clf', neighbors.KNeighborsClassifier())]) + clf.fit(X, y) + assert_lower(.9, clf.score(X, y)) if __name__ == '__main__': diff --git a/sklearn/manifold/tests/test_locally_linear.py b/sklearn/manifold/tests/test_locally_linear.py index 7dfefbea1578f839cbdcd0c2e7b439ec10afe103..78ae583dc9196edeb4f1058503369c05328fe09e 100644 --- a/sklearn/manifold/tests/test_locally_linear.py +++ b/sklearn/manifold/tests/test_locally_linear.py @@ -42,6 +42,7 @@ def test_lle_simple_grid(): rng = np.random.RandomState(0) # grid of equidistant points in 2D, out_dim = n_dim X = np.array(list(product(range(5), repeat=2))) + X = X + 1e-10 * np.random.uniform(size=X.shape) out_dim = 2 clf = manifold.LocallyLinearEmbedding(n_neighbors=5, out_dim=out_dim) tol = .1 @@ -72,6 +73,7 @@ def test_lle_manifold(): # similar test on a slightly more complex manifold X = np.array(list(product(range(20), repeat=2))) X = np.c_[X, X[:, 0] ** 2 / 20] + X = X + 1e-10 * np.random.uniform(size=X.shape) out_dim = 2 clf = manifold.LocallyLinearEmbedding(n_neighbors=5, out_dim=out_dim, random_state=0) @@ -95,22 +97,25 @@ def test_lle_manifold(): def test_pipeline(): # check that LocallyLinearEmbedding works fine as a Pipeline + # only checks that no error is raised. + # TODO check that it actually does something useful from sklearn import pipeline, datasets - iris = datasets.load_iris() + X, y = datasets.make_blobs(random_state=0) clf = pipeline.Pipeline( [('filter', manifold.LocallyLinearEmbedding()), ('clf', neighbors.KNeighborsClassifier())]) - clf.fit(iris.data, iris.target) - assert_lower(.7, clf.score(iris.data, iris.target)) + clf.fit(X, y) + assert_lower(.9, clf.score(X, y)) # Test the error raised when the weight matrix is singular def test_singular_matrix(): + import warnings from nose.tools import assert_raises M = np.ones((10, 3)) - - assert_raises(ValueError, manifold.locally_linear_embedding, - M, 2, 1, method='standard', eigen_solver='arpack') + with warnings.catch_warnings(record=True): + assert_raises(ValueError, manifold.locally_linear_embedding, + M, 2, 1, method='standard', eigen_solver='arpack') if __name__ == '__main__':