title: ValueError: Invalid parameter n_estimators for estimator LogisticRegression(random_state=42)
body: <p>I already looked at the other similar questions, but they did not help me. I'm attempting to use GridSearchCV. I'm using three pipelines to predict nfl play data. It works pretty well until the grid search part.
  Here is my code.</p>
  <pre><code>pipe_nfl1_1 = Pipeline([
          ('ssc', StandardScaler()),
          ('lr', LogisticRegression(random_state=42))
  ])
  pipe_nfl1_2 = Pipeline([
          ('mms', MinMaxScaler()),
          ('rfc', RandomForestClassifier(random_state=42))
  ])
  pipe_nfl1_3 = Pipeline([
          ('mms', MinMaxScaler()),
          ('svc', svm.SVC(random_state=42))
  ])
  pipelines1 = [pipe_nfl1_1, pipe_nfl1_2, pipe_nfl1_3]
  pipe_dict1 = {0: 'Logistic Regression', 1: 'Random Forest', 2: 'SVC'}
  for pipe in pipelines1:
      pipe.fit(X_train1, y_train1)
  print('Pipeline test accuracy for predicting 1st downs:')
  for idx, val in enumerate(pipelines1):
      print('    %s: %.4f' % (pipe_dict1[idx], val.score(X_test1, y_test1)))
  best_acc1 = 0.0
  best_clf1 = 0
  best_pipe1 = ''
  for idx, val in enumerate(pipelines1):
      if val.score(X_test1, y_test1) &gt; best_acc1:
          best_acc1 = val.score(X_test1, y_test1)
          best_pipe1 = val
          best_clf1 = idx
  best_acc1 *= 100
  print('Classifier with best accuracy for predicting 1st downs is %s with %.2f' % (pipe_dict1[best_clf1], best_acc1) + '%')
  param_grid1 = {
          'lr__n_estimators': [2, 4, 6]
  }
  grid_search1 = GridSearchCV(pipe_nfl1_1, param_grid1, cv=2) 
  
  # fine-tune the hyperparameters
  grid_search1.fit(X_train1, y_train1)
  
  # get the best model
  final_model1 = grid_search1.best_estimator_
  grid_search.best_score_
  </code></pre>
  <p>But I'm getting an error:</p>
  <pre><code>---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-33-6b0007d9b8f1&gt; in &lt;module&gt;
        2 
        3 # fine-tune the hyperparameters
  ----&gt; 4 grid_search1.fit(X_train1, y_train1)
        5 
        6 # get the best model
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\utils\validation.py in inner_f(*args, **kwargs)
       70                           FutureWarning)
       71         kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
  ---&gt; 72         return f(**kwargs)
       73     return inner_f
       74 
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\model_selection\_search.py in fit(self, X, y, groups, **fit_params)
      734                 return results
      735 
  --&gt; 736             self._run_search(evaluate_candidates)
      737 
      738         # For multi-metric evaluation, store the best_index_, best_params_ and
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\model_selection\_search.py in _run_search(self, evaluate_candidates)
     1186     def _run_search(self, evaluate_candidates):
     1187         &quot;&quot;&quot;Search all candidates in param_grid&quot;&quot;&quot;
  -&gt; 1188         evaluate_candidates(ParameterGrid(self.param_grid))
     1189 
     1190 
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\model_selection\_search.py in evaluate_candidates(candidate_params)
      706                               n_splits, n_candidates, n_candidates * n_splits))
      707 
  --&gt; 708                 out = parallel(delayed(_fit_and_score)(clone(base_estimator),
      709                                                        X, y,
      710                                                        train=train, test=test,
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\joblib\parallel.py in __call__(self, iterable)
     1027             # remaining jobs.
     1028             self._iterating = False
  -&gt; 1029             if self.dispatch_one_batch(iterator):
     1030                 self._iterating = self._original_iterator is not None
     1031 
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\joblib\parallel.py in dispatch_one_batch(self, iterator)
      845                 return False
      846             else:
  --&gt; 847                 self._dispatch(tasks)
      848                 return True
      849 
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\joblib\parallel.py in _dispatch(self, batch)
      763         with self._lock:
      764             job_idx = len(self._jobs)
  --&gt; 765             job = self._backend.apply_async(batch, callback=cb)
      766             # A job can complete so quickly than its callback is
      767             # called before we get here, causing self._jobs to
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\joblib\_parallel_backends.py in apply_async(self, func, callback)
      206     def apply_async(self, func, callback=None):
      207         &quot;&quot;&quot;Schedule a func to be run&quot;&quot;&quot;
  --&gt; 208         result = ImmediateResult(func)
      209         if callback:
      210             callback(result)
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\joblib\_parallel_backends.py in __init__(self, batch)
      570         # Don't delay the application, to avoid keeping the input
      571         # arguments in memory
  --&gt; 572         self.results = batch()
      573 
      574     def get(self):
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\joblib\parallel.py in __call__(self)
      250         # change the default number of processes to -1
      251         with parallel_backend(self._backend, n_jobs=self._n_jobs):
  --&gt; 252             return [func(*args, **kwargs)
      253                     for func, args, kwargs in self.items]
      254 
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\joblib\parallel.py in &lt;listcomp&gt;(.0)
      250         # change the default number of processes to -1
      251         with parallel_backend(self._backend, n_jobs=self._n_jobs):
  --&gt; 252             return [func(*args, **kwargs)
      253                     for func, args, kwargs in self.items]
      254 
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\model_selection\_validation.py in _fit_and_score(estimator, X, y, scorer, train, test, verbose, parameters, fit_params, return_train_score, return_parameters, return_n_test_samples, return_times, return_estimator, error_score)
      518             cloned_parameters[k] = clone(v, safe=False)
      519 
  --&gt; 520         estimator = estimator.set_params(**cloned_parameters)
      521 
      522     start_time = time.time()
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\pipeline.py in set_params(self, **kwargs)
      139         self
      140         &quot;&quot;&quot;
  --&gt; 141         self._set_params('steps', **kwargs)
      142         return self
      143 
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\utils\metaestimators.py in _set_params(self, attr, **params)
       51                 self._replace_estimator(attr, name, params.pop(name))
       52         # 3. Step parameters and other initialisation arguments
  ---&gt; 53         super().set_params(**params)
       54         return self
       55 
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\base.py in set_params(self, **params)
      259 
      260         for key, sub_params in nested_params.items():
  --&gt; 261             valid_params[key].set_params(**sub_params)
      262 
      263         return self
  
  ~\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\base.py in set_params(self, **params)
      247             key, delim, sub_key = key.partition('__')
      248             if key not in valid_params:
  --&gt; 249                 raise ValueError('Invalid parameter %s for estimator %s. '
      250                                  'Check the list of available parameters '
      251                                  'with `estimator.get_params().keys()`.' %
  
  ValueError: Invalid parameter n_estimators for estimator LogisticRegression(random_state=42). Check the list of available parameters with `estimator.get_params().keys()`.
  </code></pre>
  <p>I've done LogisticRegression.get_params().keys() to get the keys, but it returns get_params() missing 1 required positional argument: 'self'.</p>