title: Cross Validation function for logistic regression in R
body: <p>I Come from a predominantly python + scikit learn background, and I was wondering how would one obtain the cross validation accuracy for a logistic regression model in R? I was searching and surprised that there's no easy way to this. I'm looking for the equivalent:</p>
  
  <pre><code>import pandas as pd
  from sklearn.cross_validation import cross_val_score
  from sklearn.linear_model import LogisticRegression
  
  ## Assume pandas dataframe of dataset and target exist.
  
  scores = cross_val_score(LogisticRegression(),dataset,target,cv=10)
  print(scores)
  </code></pre>
  
  <p>For R: I have:</p>
  
  <pre><code>model = glm(df$Y~df$X,family=binomial')
  summary(model) 
  </code></pre>
  
  <p>And now I'm stuck. Reason being, the deviance for my R model is 1900, implying its a bad fit, but the python one gives me 85% 10 fold cross validation accuracy.. which means its good. Seems a bit strange... So i wanted to run cross val in R to see if its the same result.</p>
  
  <p>Any help is appreciated!</p>