title: Combining Principal Component Analysis and Support Vector Machine in a pipeline
body: <p>I want to combine PCA and SVM to a pipeline, to find the best combination of hyperparameters in a GridSearch.</p>
  
  <p>The following code </p>
  
  <pre><code>from sklearn.svm import SVC
  from sklearn import decomposition, datasets
  from sklearn.pipeline import Pipeline
  from sklearn.model_selection import GridSearchCV
  
  digits = datasets.load_digits()
  X_train = digits.data
  y_train = digits.target
  
  #Use Principal Component Analysis to reduce dimensionality
  # and improve generalization
  pca = decomposition.PCA()
  # Use a linear SVC 
  svm = SVC()
  # Combine PCA and SVC to a pipeline
  pipe = Pipeline(steps=[('pca', pca), ('svm', svm)])
  # Check the training time for the SVC
  n_components = [20, 40, 64]
  svm_grid = [
    {'C': [1, 10, 100, 1000], 'kernel': ['linear']},
    {'C': [1, 10, 100, 1000], 'gamma': [0.001, 0.0001], 'kernel': ['rbf']},
   ]
  estimator = GridSearchCV(pipe,
                           dict(pca__n_components=n_components,
                                svm=svm_grid))
  estimator.fit(X_train, y_train)
  </code></pre>
  
  <p>Results in an</p>
  
  <pre><code>AttributeError: 'dict' object has no attribute 'get_params'
  </code></pre>
  
  <p>There is probably something wrong with the way I define and use <code>svm_grid</code>. How can I pass this parameter combination to GridSearchCV correctly?</p>