title: Cross Validation for Logistic Regression
body: <p>I am wondering how to use cross validation in python to improve the accuracy of my logistic regression model. The dataset being used is called 'iris'. I have already successfully used cross validation for a SVM model but I am struggling to adjust my code to do the same for the logistic regression model. Here's my code so far:</p>
  
  <pre><code>from sklearn import cross_validation
  from sklearn import datasets, linear_model
  iris = datasets.load_iris()
  x_iris = iris.data
  y_iris = iris.target
  svc = svm.SVC(C=1, kernel='linear')
  k_fold = cross_validation.StratifiedKFold(y_iris, n_folds=10)  
  # labels, the     number of folders
  #for train, test in k_fold:
  #    print train, test
  scores = cross_validation.cross_val_score(svc, x_iris, y_iris, cv=k_fold,     scoring='accuracy') 
  # clf.fit() is repeatedly called inside the cross_validation.cross_val_score()
  print scores
  print 'average score = ', np.mean(scores)
  print 'std of scores = ', np.std(scores)
  </code></pre>
  
  <p>What adjustments must I make to the code to achieve successful cross validation for my logistic regression model?</p>
  
  <p>Thanks for any help.</p>