title: Logistic regression sklearn - train and apply model
body: <p>I'm new to machine learning and trying Sklearn for the first time. I have two dataframes, one with data to train a logistic regression model (with 10-fold cross-validation) and another one to predict classes ('0,1') using that model.
  Here's my code so far using bits of tutorials I found on Sklearn docs and on the Web:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  import sklearn
  from sklearn.linear_model import LogisticRegression
  from sklearn.model_selection import KFold
  from sklearn.preprocessing import normalize
  from sklearn.preprocessing import scale
  from sklearn.model_selection import cross_val_score
  from sklearn.model_selection import cross_val_predict
  from sklearn import metrics
  
  
  # Import dataframe with training data
  df = pd.read_csv('summary_44.csv')
  cols = df.columns.drop('num_class') # Data to use (num_class is the column with the classes)
  
  # Import dataframe with data to predict
  df_pred = pd.read_csv('new_predictions.csv')
  
  # Scores
  df_data = df.ix[:,:-1].values
  
  # Target
  df_target = df.ix[:,-1].values
  
  # Values to predict
  df_test = df_pred.ix[:,:-1].values
  
  # Scores' names
  df_data_names = cols.values
  
  # Scaling
  X, X_pred, y = scale(df_data), scale(df_test), df_target
  
  # Define number of folds
  kf = KFold(n_splits=10)
  kf.get_n_splits(X) # returns the number of splitting iterations in the cross-validator
  
  # Logistic regression normalizing variables
  LogReg = LogisticRegression()
  
  # 10-fold cross-validation
  scores = [LogReg.fit(X[train], y[train]).score(X[test], y[test]) for train, test in kf.split(X)]
  print scores
  
  # Predict new
  novel = LogReg.predict(X_pred)
  </code></pre>
  
  <p>Is this the correct way to implement a Logistic Regression? 
  I know that the fit() method should be used after cross-validation in order to train the model and use it for predictions. However, since I called fit() inside a list comprehension I really don't know if my model was "fitted" and can be used to make predictions.</p>