To answer 1): yes, if you set cv=number, then it will do K-fold
cross-validation with that number of folds. You can do this explicitly by
using
from sklearn.cross_validation import KFold
cv = KFold(len(data), 6)
and pass cv as an argument to GridSearchCV.
To answer question 2 I think we need some clarification: What exactly do
you want to have averaged? The way GridSearchCV works is that for a given
parameter, it will average the scores over all folds, and choose the
parameter that does best in this metric. Is this what you want? (There are
other ways of doing averaging, so we need to be sure we are talking about
the same thing)
Hope that helps,
Michael
On Wed, Jul 23, 2014 at 5:51 PM, Pagliari, Roberto <[email protected]>
wrote:
> This is an example about how to perform gridsearch with SVM.
>
>
>
> *>>> **from* *sklearn* *import* svm, grid_search, datasets
>
> *>>> *iris = datasets.load_iris()
>
> *>>> *parameters = {'kernel':('linear', 'rbf'), 'C':[1, 10]}
>
> *>>> *svr = svm.SVC()
>
> *>>> *clf = grid_search.GridSearchCV(svr, parameters)
>
> *>>> *clf.fit(iris.data, iris.target)
>
>
>
> I have the following two questions:
>
>
>
> 1. If I set cv=6, will k-fold automatically be selected? If not,
> how to I set it?
>
> 2. How do I specify that the best estimator parameters should be
> average of the output from the k folds, or is it done by default?
>
>
>
> Thank you,
>
>
>
>
> ------------------------------------------------------------------------------
> Want fast and easy access to all the code in your enterprise? Index and
> search up to 200,000 lines of code with a free copy of Black Duck
> Code Sight - the same software that powers the world's largest code
> search on Ohloh, the Black Duck Open Hub! Try it now.
> http://p.sf.net/sfu/bds
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general