title: How do I resolve the "ValueError: not enough values to unpack" in this sklearn code?
body: <p>Setting up a basic pipeline for Titanic Kaggle data, but am getting the error: <code>ValueError: not enough values to unpack (expected 3, got 2)</code>.</p>
  
  <p>While there are a handful of SO posts on this error, they don't quite line up, or provide solid method for diagnosing this problem, let alone a solution.  The error's traceback is vague, unfortunately. I've commented out most lines and rerun the code to see if I could narrow down which </p>
  
  <p>Here's a sample of the data:</p>
  
  <pre><code>PassengerId Pclass  Sex     Age     SibSp   Parch   Fare    Embarked    Title
  892           3     male    34.5      0       0     7.8292      Q       Mr
  893           3     female  47.0      1       0     7.0000      S       Mrs
  894           2     male    62.0      0       0     9.6875      Q       Mr
  895           3     male    27.0      0       0     8.6625      S       Mr
  896           3     female  22.0      1       1     12.2875     S       Mrs
  </code></pre>
  
  <p>Here's the pipeline code I'm working with: </p>
  
  <pre><code>from sklearn.pipeline import Pipeline
  
  from sklearn.compose import ColumnTransformer
  from sklearn.impute import SimpleImputer
  from sklearn.preprocessing import OneHotEncoder
  
  from sklearn.linear_model import LogisticRegression
  from sklearn.model_selection import GridSearchCV
  
  
  #Create a column transformer to impute missing values and one-hot encode specific columns
  col_transform = ColumnTransformer(transformers=[
                                                  ('one_hot', OneHotEncoder(categories='auto', sparse=False), ['Sex', 'Embarked', 'Title']), 
                                                  ('imputer', SimpleImputer(strategy='median'))], 
                                    remainder='passthrough')
  
  #Create a pipeline for the column transformer and logistic regressor
  pipe = Pipeline(steps=[('encoding', col_transform),
                         ('logistic_reg', LogisticRegression(max_iter=10000, tol=0.1))])
  param_grid = {
  #     'logistic_reg__class_weight':[None, 'balanced'],
  #     'logistic_reg__solver':['lbfgs', 'liblinear', 'newton-cg']
  }
  
  clf = GridSearchCV(pipe, param_grid=param_grid, cv=5, verbose=True, n_jobs=-1)
  
  best_clf=clf.fit(X_train, y_train)
  </code></pre>
  
  <p><em>Question:</em>  Any ideas why I'm getting the error mentioned above?</p>
  
  <p><em>EDIT:</em>  Here's the full error</p>
  
  <pre><code>_RemoteTraceback                          Traceback (most recent call last)
  _RemoteTraceback: 
  """
  Traceback (most recent call last):
    File "C:\Users\Lofgran\AppData\Local\Continuum\anaconda3\lib\site-packages\joblib\externals\loky\process_executor.py", line 418, in _process_worker
      r = call_item()
    File "C:\Users\Lofgran\AppData\Local\Continuum\anaconda3\lib\site-packages\joblib\externals\loky\process_executor.py", line 272, in __call__
      return self.fn(*self.args, **self.kwargs)
    File "C:\Users\Lofgran\AppData\Local\Continuum\anaconda3\lib\site-packages\joblib\_parallel_backends.py", line 567, in __call__
      return self.func(*args, **kwargs)
    File "C:\Users\Lofgran\AppData\Local\Continuum\anaconda3\lib\site-packages\joblib\parallel.py", line 225, in __call__
      for func, args, kwargs in self.items]
    File "C:\Users\Lofgran\AppData\Local\Continuum\anaconda3\lib\site-packages\joblib\parallel.py", line 225, in &lt;listcomp&gt;
      for func, args, kwargs in self.items]
    File "C:\Users\Lofgran\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\model_selection\_validation.py", line 516, in _fit_and_score
      estimator.fit(X_train, y_train, **fit_params)
    File "C:\Users\Lofgran\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\pipeline.py", line 352, in fit
      Xt, fit_params = self._fit(X, y, **fit_params)
    File "C:\Users\Lofgran\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\pipeline.py", line 317, in _fit
      **fit_params_steps[name])
    File "C:\Users\Lofgran\AppData\Local\Continuum\anaconda3\lib\site-packages\joblib\memory.py", line 355, in __call__
      return self.func(*args, **kwargs)
    File "C:\Users\Lofgran\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\pipeline.py", line 716, in _fit_transform_one
      res = transformer.fit_transform(X, y, **fit_params)
    File "C:\Users\Lofgran\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\compose\_column_transformer.py", line 472, in fit_transform
      self._validate_transformers()
    File "C:\Users\Lofgran\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\compose\_column_transformer.py", line 265, in _validate_transformers
      names, transformers, _ = zip(*self.transformers)
  ValueError: not enough values to unpack (expected 3, got 2)
  """
  
  The above exception was the direct cause of the following exception:
  
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-17-6a051cf930ab&gt; in &lt;module&gt;
       25 clf = GridSearchCV(pipe, param_grid=param_grid, cv=5, verbose=True, n_jobs=-1) #5 fold cross-validation; n_jobs=use all processors
       26 
  ---&gt; 27 best_clf=clf.fit(X_train, y_train)
  
  ~\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\model_selection\_search.py in fit(self, X, y, groups, **fit_params)
      686                 return results
      687 
  --&gt; 688             self._run_search(evaluate_candidates)
      689 
      690         # For multi-metric evaluation, store the best_index_, best_params_ and
  
  ~\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\model_selection\_search.py in _run_search(self, evaluate_candidates)
     1147     def _run_search(self, evaluate_candidates):
     1148         """Search all candidates in param_grid"""
  -&gt; 1149         evaluate_candidates(ParameterGrid(self.param_grid))
     1150 
     1151 
  
  ~\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\model_selection\_search.py in evaluate_candidates(candidate_params)
      665                                for parameters, (train, test)
      666                                in product(candidate_params,
  --&gt; 667                                           cv.split(X, y, groups)))
      668 
      669                 if len(out) &lt; 1:
  
  ~\AppData\Local\Continuum\anaconda3\lib\site-packages\joblib\parallel.py in __call__(self, iterable)
      932 
      933             with self._backend.retrieval_context():
  --&gt; 934                 self.retrieve()
      935             # Make sure that we get a last message telling us we are done
      936             elapsed_time = time.time() - self._start_time
  
  ~\AppData\Local\Continuum\anaconda3\lib\site-packages\joblib\parallel.py in retrieve(self)
      831             try:
      832                 if getattr(self._backend, 'supports_timeout', False):
  --&gt; 833                     self._output.extend(job.get(timeout=self.timeout))
      834                 else:
      835                     self._output.extend(job.get())
  
  ~\AppData\Local\Continuum\anaconda3\lib\site-packages\joblib\_parallel_backends.py in wrap_future_result(future, timeout)
      519         AsyncResults.get from multiprocessing."""
      520         try:
  --&gt; 521             return future.result(timeout=timeout)
      522         except LokyTimeoutError:
      523             raise TimeoutError()
  
  ~\AppData\Local\Continuum\anaconda3\lib\concurrent\futures\_base.py in result(self, timeout)
      433                 raise CancelledError()
      434             elif self._state == FINISHED:
  --&gt; 435                 return self.__get_result()
      436             else:
      437                 raise TimeoutError()
  
  ~\AppData\Local\Continuum\anaconda3\lib\concurrent\futures\_base.py in __get_result(self)
      382     def __get_result(self):
      383         if self._exception:
  --&gt; 384             raise self._exception
      385         else:
      386             return self._result
  
  ValueError: not enough values to unpack (expected 3, got 2)
  </code></pre>
  
  <p><em>Edit 2:</em> </p>
  
  <pre><code>col_transform = ColumnTransformer(transformers=[ 
                                                  ('imputer', SimpleImputer(missing_values=np.nan, strategy='median')),
                                                  ('one_hot', OneHotEncoder(categories='auto', sparse=False))], 
                                    remainder='passthrough')
  </code></pre>