title: How to use 'max_features' in Gridsearch when combining with RFECV?
body: <p>Thank you for answering in advance. This is my first post and I am relatively new to python, so I apologize if I have formatted something terribly.</p>
  
  <p>I am trying to combine recursive feature elimination and grid search in sklearn to determine the best combination of hyperparameters and number of features. When using the code below, I get <strong>max_features must be in (0, n_features] Estimator fit failed.</strong> for anything other than max_features is 1. I have over 300 features in my dataset, many of them likely unimportant.</p>
  
  <p>'''</p>
  
  <pre><code>    param_dist = {'estimator__n_estimators': [i for i in range(11, 121, 10)],
                    'estimator__criterion': ['gini', 'entropy']}
                    'estimator__max_features': [i for i in range(1, 10)]}
  
  
  
      estimator = sklearn.ensemble.RandomForestClassifier(n_jobs=-1, random_state=42, bootstrap=True, verbose=True, max_features='auto')
  
      selector = sklearn.feature_selection.RFECV(estimator=estimator, step=1, cv=5,
                                                  scoring='accuracy')
  
      rf_nested = sklearn.model_selection.GridSearchCV(estimator=selector, param_grid=param_dist, cv=5,
                                                          scoring='accuracy', n_jobs=-1, refit=True, return_train_score=True)
  
  
      rf_nested.fit(X_train, y_train)
  </code></pre>
  
  <p>'''</p>