title: How to tune parameter of SVM in a BaggingClassifier
body: <p>I am trying to do a sentiment analysis of movie reviews using C-support Vector Classification. The code below returns the error </p>
  
  <blockquote>
    <p>AttributeError: Invalid parameter C for estimator BaggingClassifier. </p>
  </blockquote>
  
  <p>The error shows up when trying to do the grid search, as far as I can tell. I have tried pulling the available parameters but when I use something from there instead I get the same error. When the code is run, it seems like it prints a few jobs before running into a problem but it doesn't make sense to me that some attempts would work while others do not. I have looked everywhere and while some similar questions have been answered I wasn't able to apply their solutions to my problem. What am I not seeing?  </p>
  
  <pre><code>token = RegexpTokenizer(r'[a-zA-Z0-9]+')
  en_stopwords = set(stopwords.words("english"))
  
  
  tf = TfidfVectorizer(lowercase=True,
                       tokenizer=token.tokenize,
                       analyzer='word',
                       stop_words=en_stopwords,
                       ngram_range=(1, 1))
  
  
  # text_tf = tf.fit_transform(data['Phrase'])
  
  X_train, X_test, y_train, y_test = train_test_split(data['Phrase'], data['Sentiment'], test_size=0.3, random_state=1)
  
  kfolds = StratifiedKFold(n_splits=3, shuffle=True, random_state=1)
  
  np.random.seed(1)
  
  n_estimators=10
  svc = BaggingClassifier(SVC(probability=True, kernel="linear", class_weight="balanced"),
                          max_samples=1.0 / n_estimators, n_estimators=n_estimators)
  
  
  pipeline_svm = Pipeline([('tf', tf), ('svc', svc)])
  
  
  grid_svc = GridSearchCV(pipeline_svm,
                          param_grid={'svc__C': [1,10]},
                          cv=kfolds,
                          scoring='roc_auc',
                          verbose=50,
                          n_jobs=-1)
  
  
  grid_svc.fit(X_train, y_train)
  grid_svc.score(X_test, y_test)
  
  
  
  
  
  
  sklearn.externals.joblib.externals.loky.process_executor._RemoteTraceback: 
  """
  Traceback (most recent call last):
    File "C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\externals\loky\process_executor.py", line 418, in _process_worker
      r = call_item()
    File "C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\externals\loky\process_executor.py", line 272, in __call__
      return self.fn(*self.args, **self.kwargs)
    File "C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\_parallel_backends.py", line 567, in __call__
      return self.func(*args, **kwargs)
    File "C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py", line 225, in __call__
      for func, args, kwargs in self.items]
    File "C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py", line 225, in &lt;listcomp&gt;
      for func, args, kwargs in self.items]
    File "C:\Anaconda3\lib\site-packages\sklearn\model_selection\_validation.py", line 514, in _fit_and_score
      estimator.set_params(**parameters)
    File "C:\Anaconda3\lib\site-packages\sklearn\pipeline.py", line 147, in set_params
      self._set_params('steps', **kwargs)
    File "C:\Anaconda3\lib\site-packages\sklearn\utils\metaestimators.py", line 52, in _set_params
      super(_BaseComposition, self).set_params(**params)
    File "C:\Anaconda3\lib\site-packages\sklearn\base.py", line 222, in set_params
      valid_params[key].set_params(**sub_params)
    File "C:\Anaconda3\lib\site-packages\sklearn\base.py", line 213, in set_params
      (key, self))
  ValueError: Invalid parameter C for estimator BaggingClassifier(base_estimator=SVC(C=1.0, cache_size=200, class_weight='balanced', coef0=0.0,
    decision_function_shape='ovr', degree=3, gamma='auto_deprecated',
    kernel='linear', max_iter=-1, probability=True, random_state=None,
    shrinking=True, tol=0.001, verbose=False),
           bootstrap=True, bootstrap_features=False, max_features=1.0,
           max_samples=0.1, n_estimators=10, n_jobs=None, oob_score=False,
           random_state=None, verbose=0, warm_start=False). Check the list of available parameters with `estimator.get_params().keys()`.
  """
  The above exception was the direct cause of the following exception:
  Traceback (most recent call last):
    File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3267, in run_code
      exec(code_obj, self.user_global_ns, self.user_ns)
    File "&lt;ipython-input-3-5e5bd8e0d8dd&gt;", line 1, in &lt;module&gt;
      grid_svm.fit(X_train, y_train)
    File "C:\Anaconda3\lib\site-packages\sklearn\model_selection\_search.py", line 722, in fit
      self._run_search(evaluate_candidates)
    File "C:\Anaconda3\lib\site-packages\sklearn\model_selection\_search.py", line 1191, in _run_search
      evaluate_candidates(ParameterGrid(self.param_grid))
    File "C:\Anaconda3\lib\site-packages\sklearn\model_selection\_search.py", line 711, in evaluate_candidates
      cv.split(X, y, groups)))
    File "C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py", line 930, in __call__
      self.retrieve()
    File "C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py", line 833, in retrieve
      self._output.extend(job.get(timeout=self.timeout))
    File "C:\Anaconda3\lib\site-packages\sklearn\externals\joblib\_parallel_backends.py", line 521, in wrap_future_result
      return future.result(timeout=timeout)
    File "C:\Anaconda3\lib\concurrent\futures\_base.py", line 432, in result
      return self.__get_result()
    File "C:\Anaconda3\lib\concurrent\futures\_base.py", line 384, in __get_result
      raise self._exception
  ValueError: Invalid parameter C for estimator BaggingClassifier(base_estimator=SVC(C=1.0, cache_size=200, class_weight='balanced', coef0=0.0,
    decision_function_shape='ovr', degree=3, gamma='auto_deprecated',
    kernel='linear', max_iter=-1, probability=True, random_state=None,
    shrinking=True, tol=0.001, verbose=False),
           bootstrap=True, bootstrap_features=False, max_features=1.0,
           max_samples=0.1, n_estimators=10, n_jobs=None, oob_score=False,
           random_state=None, verbose=0, warm_start=False). Check the list of available parameters with `estimator.get_params().keys()`.
  </code></pre>