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
b93105e8
Commit
b93105e8
authored
13 years ago
by
Gael Varoquaux
Browse files
Options
Downloads
Patches
Plain Diff
DOC: faster and more meaningful example
parent
e6ecf577
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/plot_digits_pipe.py
+11
-9
11 additions, 9 deletions
examples/plot_digits_pipe.py
with
11 additions
and
9 deletions
examples/plot_digits_pipe.py
+
11
−
9
View file @
b93105e8
...
...
@@ -3,10 +3,13 @@
"""
=========================================================
Pipelining
Pipelining
: chaining a PCA and a logistic regression
=========================================================
This plot is generated by pipelining a PCA and a logisitic regression.
The PCA does an unsupervised dimensionality reduction, while the logistic
regression does the prediction.
We use a GridSearchCV to set the dimensionality of the PCA
"""
print
__doc__
...
...
@@ -50,18 +53,17 @@ scores = cross_validation.cross_val_score(pipe, X_digits, y_digits, n_jobs=-1)
from
sklearn.grid_search
import
GridSearchCV
n_components
=
[
10
,
15
,
20
,
30
,
40
,
5
0
,
64
]
Cs
=
np
.
logspace
(
-
4
,
4
,
16
)
n_components
=
[
20
,
4
0
,
64
]
Cs
=
np
.
logspace
(
-
4
,
4
,
3
)
#Parameters of pipelines can be set using ‘__’ separated parameter names:
estimator
=
GridSearchCV
(
pipe
,
dict
(
pca__n_components
=
n_components
,
logistic__C
=
Cs
),
n_jobs
=-
1
)
logistic__C
=
Cs
))
estimator
.
fit
(
X_digits
,
y_digits
)
# Plot the PCA spectrum
pca
.
fit
(
X_digits
)
pl
.
axvline
(
estimator
.
best_estimator_
.
named_steps
[
'
pca
'
].
n_components
,
linestyle
=
'
:
'
,
label
=
'
n_components chosen
'
)
pl
.
legend
(
prop
=
dict
(
size
=
12
))
pl
.
show
()
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