title: how to use joblib with scikitlearn to crossvalidate in parallel
body: <p>I am trying to execute cross validation folds in parallel with the joblib library in python.</p>
  
  <p>I have the following sample code:</p>
  
  <pre><code>from sklearn.model_selection import KFold
  import numpy as np
  from sklearn.metrics import classification_report, confusion_matrix, f1_score
  from sklearn import svm
  from sklearn import datasets
  from sklearn.model_selection import StratifiedKFold
  from sklearn.svm import LinearSVC
  
  iris = datasets.load_iris()
  X, Y = iris.data, iris.target
  
  skf = StratifiedKFold(n_splits=5)
  
  #clf = svm.LinearSVC()
  clf = svm.SVC(kernel='rbf')
  #clf = svm.SVC(kernel='linear')
  
  f1_list = []
  
  for train_index, test_index in skf.split(X, Y):
      X_train, X_test = X[train_index], X[test_index]
      y_train, y_test = Y[train_index], Y[test_index]
      clf.fit(X_train, y_train)
      Y_predict = clf.predict(X_test)
      f1 = f1_score(y_test, Y_predict, average='weighted')
      print(f1)
      conf_mat = confusion_matrix(y_test, Y_predict)
      print(conf_mat)
      f1_list.append(f1)
  print(f1_list)
  </code></pre>
  
  <p>I would like to execute the for loop in parallel to obtain accuracy scores in parallel for each of the folds.</p>
  
  <p>I believe the joblib library has to be used in the following way:</p>
  
  <pre><code>from math import sqrt
  from joblib import Parallel, delayed
  def producer():
       for i in range(6):
          print('Produced %s' % i)
          yield i
  out = Parallel(n_jobs=2, verbose=100, pre_dispatch='1.5*n_jobs')(
                  delayed(sqrt)(i) for i in producer())
  </code></pre>
  
  <p>any suggestions on how to accomplish the parallel task integration?</p>