Hi Conrad.
The Pipeline is designed to do exactly this:
http://scikit-learn.org/dev/modules/generated/sklearn.pipeline.Pipeline.html#sklearn.pipeline.Pipeline
Example here:
http://scikit-learn.org/dev/auto_examples/feature_selection_pipeline.html#example-feature-selection-pipeline-py
You can use it to build an estimator that does both things and has both
parameters.
@devs: Is there a piece in the user guide that describes the pipeline? I
can't find it.
Cheers,
Andy
On 03/21/2012 08:06 PM, Conrad Lee wrote:
I want to do a grid search that does two things at once: chooses the
right value for C, the regularization parameter, and does feature
selection with recursive feature elimination.
As a reminder, here's how you usually use the Recursive Feature
Elimination Cross Validation (RFECV) method:
from sklearn.feature_selection import RFECV
from sklearn.svm import SVR
estimator = SVR(kernel="linear", C=100)
selector = RFECV(estimator, step=1, cv=5)
selector = selector.fit(X, y)
I also I tried the following:
parameters = {"estimator": (LogisticRegression(C=100)
, LogisticRegression(C=1000))}
clf = GridSearchCV(RFECV(step=1 cv=StratifiedKFold(y, 2)),
loss_func=zero_one)
clf.fit(X, y)
Unsurprisingly, the above code doesn't work because it's not possible
to initialize a RFECV object without an estimator. But I can't pass
it an estimator yet because I want to vary the value of C that is used
in initializing the estimator. Can someone show me how this is done?
Thanks,
Conrad
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general