title: Using explicit (predefined) validation set for grid search with sklearn
body: <p>I have a dataset, which has previously been split into 3 sets: train, validation and test. These sets have to be used as given in order to compare the performance across different algorithms.</p>
  
  <p>I would now like to optimize the parameters of my SVM using the validation set. However, I cannot find how to input the validation set explicitly into <code>sklearn.grid_search.GridSearchCV()</code>. Below is some code I've previously used for doing K-fold cross-validation on the training set. However, for this problem I need to use the validation set as given. How can I do that?</p>
  
  <pre class="lang-py prettyprint-override"><code>from sklearn import svm, cross_validation
  from sklearn.grid_search import GridSearchCV
  
  # (some code left out to simplify things)
  
  skf = cross_validation.StratifiedKFold(y_train, n_folds=5, shuffle = True)
  clf = GridSearchCV(svm.SVC(tol=0.005, cache_size=6000,
                               class_weight=penalty_weights),
                       param_grid=tuned_parameters,
                       n_jobs=2,
                       pre_dispatch="n_jobs",
                       cv=skf,
                       scoring=scorer)
  clf.fit(X_train, y_train)
  </code></pre>