-
-
Notifications
You must be signed in to change notification settings - Fork 26k
WIP Grid search convenience class. #1034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e2ab19b
ENH added ResultGrid class, new interface to GridSearchCV results
amueller a2eae0a
DOC some docstrings
amueller 6513593
DOC started on example.
amueller b35bca5
Slight change in interface, Updated examples
amueller 0d8ad7c
trying to get "max" to work, but it is not so easy
amueller 45b2969
FIX for max in grid scoring, simplified
amueller 3e84b08
DOC fixed docstring
amueller 43bed9e
FIX removed debugging code
amueller aa91166
COSMIT addressed @agramfort's comments.
amueller 3b14a67
COSMIT rename accumulated to accumulate, some adjustments in figures.
amueller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
===================================================== | ||
Visualizing results of high dimensional grid searches | ||
===================================================== | ||
|
||
Often one is faced with combining feature extraction, feature selection | ||
and classification into a complex pipeline. | ||
Each individual step usually has many tunable parameters. Finding the | ||
important parameters for a given task and picking robust settings is often | ||
hard. | ||
|
||
This example show how to visualize results of a grid search with | ||
many interacting parameters. | ||
The ``DecisionTreeClassifier`` is a good model for a complex pipeline as there | ||
are many parameters to tweak, but often only few have significant influence. | ||
""" | ||
print __doc__ | ||
|
||
import pylab as pl | ||
|
||
from sklearn.datasets import make_classification | ||
from sklearn.grid_search import GridSearchCV | ||
from sklearn.tree import DecisionTreeClassifier | ||
|
||
X, y = make_classification(n_samples=100, n_features=10, random_state=0) | ||
|
||
param_grid = {'max_depth': range(1, 8), 'min_samples_split': [1, 2, 3, 4], | ||
'max_features': [1, 3, 5, 8, 10]} | ||
|
||
grid_search = GridSearchCV(DecisionTreeClassifier(), param_grid=param_grid, | ||
cv=5) | ||
grid_search.fit(X, y) | ||
|
||
cv_scores = grid_search.scores_ | ||
|
||
fig, axes = pl.subplots(1, 3) | ||
axes = axes.ravel() | ||
for ax, param in zip(axes, cv_scores.params): | ||
means, errors = cv_scores.accumulate(param, 'max') | ||
ax.boxplot(cv_scores.values[param], means, yerr=errors) | ||
ax.set_xlabel(param) | ||
ax.set_ylabel("accuracy") | ||
ax.set_ylim(0.6, 0.95) | ||
fig.set_size_inches((12, 4), forward=True) | ||
pl.subplots_adjust(left=0.07, right=0.95, bottom=0.15, wspace=0.26) | ||
pl.show() |
This file contains hidde
8000
n or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On this plot, I'd also set a title to the color bar