From 2d5788f8bea56afa22653e62270afa30f776e9ce Mon Sep 17 00:00:00 2001 From: Olivier Grisel <olivier.grisel@ensta.org> Date: Mon, 1 Nov 2010 17:24:15 +0100 Subject: [PATCH] cosmits --- scikits/learn/grid_search.py | 45 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/scikits/learn/grid_search.py b/scikits/learn/grid_search.py index 6c434561df..5524f09c85 100644 --- a/scikits/learn/grid_search.py +++ b/scikits/learn/grid_search.py @@ -28,26 +28,26 @@ except: def iter_grid(param_grid): - """ Generators on the combination of the various parameter lists given. + """Generators on the combination of the various parameter lists given - Parameters - ----------- - kwargs: keyword arguments, lists - Each keyword argument must be a list of values that should - be explored. - - Returns - -------- - params: dictionary - Dictionnary with the input parameters taking the various - values succesively. - - Examples - --------- - >>> from scikits.learn.grid_search import iter_grid - >>> param_grid = {'a':[1, 2], 'b':[True, False]} - >>> list(iter_grid(param_grid)) - [{'a': 1, 'b': True}, {'a': 1, 'b': False}, {'a': 2, 'b': True}, {'a': 2, 'b': False}] + Parameters + ----------- + kwargs: keyword arguments, lists + Each keyword argument must be a list of values that should + be explored. + + Returns + -------- + params: dictionary + Dictionnary with the input parameters taking the various + values succesively. + + Examples + --------- + >>> from scikits.learn.grid_search import iter_grid + >>> param_grid = {'a':[1, 2], 'b':[True, False]} + >>> list(iter_grid(param_grid)) + [{'a': 1, 'b': True}, {'a': 1, 'b': False}, {'a': 2, 'b': True}, {'a': 2, 'b': False}] """ if hasattr(param_grid, 'has_key'): @@ -64,6 +64,7 @@ def iter_grid(param_grid): def fit_grid_point(X, y, base_clf, clf_params, cv, loss_func, iid, **fit_params): """Run fit on one set of parameters + Returns the score and the instance of the classifier """ # update parameters of the classifier after a copy of its base structure @@ -97,10 +98,8 @@ def fit_grid_point(X, y, base_clf, clf_params, cv, loss_func, iid, return score, clf -################################################################################ class GridSearchCV(BaseEstimator): - """ - Grid search on the parameters of a classifier. + """Grid search on the parameters of a classifier Important members are fit, predict. @@ -178,6 +177,7 @@ class GridSearchCV(BaseEstimator): def fit(self, X, y, refit=True, cv=None, **kw): """Run fit with all sets of parameters + Returns the best classifier Parameters @@ -230,7 +230,6 @@ class GridSearchCV(BaseEstimator): return self - def score(self, X, y=None): # This method is overridden during the fit if the best estimator # found has a score function. -- GitLab