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
33a0f4e0
Commit
33a0f4e0
authored
14 years ago
by
Gael Varoquaux
Browse files
Options
Downloads
Patches
Plain Diff
DOC: Better plotting in RFE example
parent
320ee33a
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
examples/plot_rfe_with_cross_validation.py
+10
-1
10 additions, 1 deletion
examples/plot_rfe_with_cross_validation.py
scikits/learn/feature_selection/rfe.py
+1
-0
1 addition, 0 deletions
scikits/learn/feature_selection/rfe.py
with
11 additions
and
1 deletion
examples/rfe_with_cross_validation.py
→
examples/
plot_
rfe_with_cross_validation.py
+
10
−
1
View file @
33a0f4e0
...
...
@@ -7,6 +7,7 @@ Recursive feature elimination with automatic tuning of the
number of features selected with cross-validation
"""
print
__doc__
import
numpy
as
np
from
scikits.learn.svm
import
SVC
from
scikits.learn.cross_val
import
StratifiedKFold
...
...
@@ -30,6 +31,14 @@ print 'Optimal number of features : %d' % rfecv.support_.sum()
import
pylab
as
pl
pl
.
figure
()
pl
.
plot
(
rfecv
.
cv_scores_
)
pl
.
semilogx
(
rfecv
.
n_features_
,
rfecv
.
cv_scores_
)
pl
.
xlabel
(
'
Number of features selected
'
)
pl
.
ylabel
(
'
Cross validation score (nb of misclassifications)
'
)
# 15 ticks regularly-space in log
x_ticks
=
np
.
unique
(
np
.
logspace
(
np
.
log10
(
2
),
np
.
log10
(
rfecv
.
n_features_
.
max
()),
15
,
).
astype
(
np
.
int
))
pl
.
xticks
(
x_ticks
,
x_ticks
)
pl
.
show
()
This diff is collapsed.
Click to expand it.
scikits/learn/feature_selection/rfe.py
+
1
−
0
View file @
33a0f4e0
...
...
@@ -181,6 +181,7 @@ class RFECV(RFE):
clf
=
self
.
estimator
n_models
=
np
.
max
(
self
.
ranking_
)
self
.
cv_scores_
=
np
.
zeros
(
n_models
)
self
.
n_features_
=
np
.
bincount
(
self
.
ranking_
)[::
-
1
].
cumsum
()[
-
2
::
-
1
]
for
train
,
test
in
cv
:
ranking_
=
rfe
.
fit
(
X
[
train
],
y
[
train
]).
ranking_
...
...
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