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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ian Johnson
scikit-learn
Commits
6fee3da9
Commit
6fee3da9
authored
13 years ago
by
Peter Prettenhofer
Browse files
Options
Downloads
Patches
Plain Diff
added max_features to gbrt regularization example
parent
89cb7056
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/ensemble/plot_gradient_boosting_regularization.py
+15
-9
15 additions, 9 deletions
examples/ensemble/plot_gradient_boosting_regularization.py
with
15 additions
and
9 deletions
examples/ensemble/plot_gradient_boosting_regularization.py
+
15
−
9
View file @
6fee3da9
...
...
@@ -6,10 +6,15 @@ Gradient Boosting regularization
Illustration of the effect of different regularization strategies
for Gradient Boosting. The example is taken from Hastie et al 2009.
The loss function used is binomial deviance. In combination with
shrinkage, stochastic gradient boosting (Sample 0.5) can produce
more accurate models.
The loss function used is binomial deviance. Regularization via
shrinkage (``learn_rate < 1.0``) improves performance considerably.
In combination with shrinkage, stochastic gradient boosting
(``subsample < 1.0``) can produce more accurate models by reducing the
variance via bagging.
Subsampling without shrinkage usually does poorly.
Another strategy to reduce the variance is by subsampling the features
analogous to the random splits in Random Forests
(via the ``max_features`` parameter).
.. [1] T. Hastie, R. Tibshirani and J. Friedman,
"
Elements of Statistical
Learning Ed. 2
"
, Springer, 2009.
...
...
@@ -39,12 +44,14 @@ pl.figure()
for
label
,
color
,
setting
in
[(
'
No shrinkage
'
,
'
orange
'
,
{
'
learn_rate
'
:
1.0
,
'
subsample
'
:
1.0
}),
(
'
Shrink
=0.1
'
,
'
turquoise
'
,
(
'
learn_rate
=0.1
'
,
'
turquoise
'
,
{
'
learn_rate
'
:
0.1
,
'
subsample
'
:
1.0
}),
(
'
S
ample=0.5
'
,
'
blue
'
,
(
'
subs
ample=0.5
'
,
'
blue
'
,
{
'
learn_rate
'
:
1.0
,
'
subsample
'
:
0.5
}),
(
'
Shrink=0.1, Sample=0.5
'
,
'
gray
'
,
{
'
learn_rate
'
:
0.1
,
'
subsample
'
:
0.5
})]:
(
'
learn_rate=0.1, subsample=0.5
'
,
'
gray
'
,
{
'
learn_rate
'
:
0.1
,
'
subsample
'
:
0.5
}),
(
'
learn_rate=0.1, max_features=2
'
,
'
magenta
'
,
{
'
learn_rate
'
:
0.1
,
'
max_features
'
:
2
})]:
params
=
dict
(
original_params
)
params
.
update
(
setting
)
...
...
@@ -57,10 +64,9 @@ for label, color, setting in [('No shrinkage', 'orange',
for
i
,
y_pred
in
enumerate
(
clf
.
staged_decision_function
(
X_test
)):
test_deviance
[
i
]
=
clf
.
loss_
(
y_test
,
y_pred
)
pl
.
plot
(
np
.
arange
(
test_deviance
.
shape
[
0
])
+
1
,
test_deviance
,
'
-
'
,
pl
.
plot
(
(
np
.
arange
(
test_deviance
.
shape
[
0
])
+
1
)[::
5
]
,
test_deviance
[::
5
]
,
'
-
'
,
color
=
color
,
label
=
label
)
pl
.
title
(
'
Deviance
'
)
pl
.
legend
(
loc
=
'
upper left
'
)
pl
.
xlabel
(
'
Boosting Iterations
'
)
pl
.
ylabel
(
'
Test Set Deviance
'
)
...
...
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