Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scikit-learn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ian Johnson
scikit-learn
Commits
a0498b65
Commit
a0498b65
authored
13 years ago
by
Andreas Mueller
Browse files
Options
Downloads
Patches
Plain Diff
MISC don't use iris in testing as it has duplicate data entries. Add some noise to simple examples.
parent
80e6ec2e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
sklearn/manifold/tests/test_isomap.py
+4
-4
4 additions, 4 deletions
sklearn/manifold/tests/test_isomap.py
sklearn/manifold/tests/test_locally_linear.py
+9
-6
9 additions, 6 deletions
sklearn/manifold/tests/test_locally_linear.py
with
13 additions
and
10 deletions
sklearn/manifold/tests/test_isomap.py
+
4
−
4
View file @
a0498b65
...
...
@@ -111,12 +111,12 @@ def test_transform():
def
test_pipeline
():
# check that Isomap works fine as a transformer in a Pipeline
iris
=
datasets
.
load_iris
(
)
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__
'
:
...
...
This diff is collapsed.
Click to expand it.
sklearn/manifold/tests/test_locally_linear.py
+
9
−
6
View file @
a0498b65
...
...
@@ -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
)
...
...
@@ -96,19 +98,20 @@ def test_lle_manifold():
def
test_pipeline
():
# check that LocallyLinearEmbedding works fine as a Pipeline
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
))
with
warnings
.
catch_warnings
(
record
=
True
):
assert_raises
(
ValueError
,
manifold
.
locally_linear_embedding
,
M
,
2
,
1
,
method
=
'
standard
'
,
eigen_solver
=
'
arpack
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment