title: Use both Recursive Feature Eliminiation and Grid Search in SciKit-Learn
body: <p>I have a machine learning problem and want to optimize my SVC estimators as well as the feature selection.</p>
  
  <p>For optimizing SVC estimators I use essentially the code from the <a href="http://scikit-learn.org/stable/auto_examples/model_selection/grid_search_digits.html#example-model-selection-grid-search-digits-py" rel="nofollow noreferrer">docs</a>. Now my question is, how can I combine this with <a href="http://scikit-learn.org/stable/auto_examples/feature_selection/plot_rfe_with_cross_validation.html#example-feature-selection-plot-rfe-with-cross-validation-py" rel="nofollow noreferrer">recursive feature elimination cross validation (RCEV)</a>? That is, for each estimator-combination I want to do the RCEV in order to determine the best combination of estimators and features.</p>
  
  <p>I tried the solution from <a href="https://stackoverflow.com/questions/31784392/how-can-i-avoid-using-estimator-params-when-using-rfecv-nested-within-gridsearch">this thread</a>, but it yields the following error:</p>
  
  <pre><code>ValueError: Invalid parameter C for estimator RFECV. Check the list of available parameters with `estimator.get_params().keys()`.
  </code></pre>
  
  <p>My code looks like this: </p>
  
  <pre><code>tuned_parameters = [{'kernel': ['rbf'], 'gamma': [1e-4,1e-3],'C': [1,10]},
                      {'kernel': ['linear'],'C': [1, 10]}]
  
  estimator = SVC(kernel="linear")
  selector = RFECV(estimator, step=1, cv=3, scoring=None)
  clf = GridSearchCV(selector, tuned_parameters, cv=3)
  clf.fit(X_train, y_train)
  </code></pre>
  
  <p>The error appears at <code>clf = GridSearchCV(selector, tuned_parameters, cv=3)</code>.</p>