title: cross_val_score on Windows10, error with parallel-computing
body: <p>I encountered an error when I tried to use <em>cross_val_score</em> with <em>n_job</em> not equal to 1.</p>
  
  <p>My system was Intel-i7 cpu, Windows10, python3.6, Spyder.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>from numpy.random import randn
  import pandas as pd
  from keras.wrappers.scikit_learn import KerasClassifier
  from sklearn.model_selection import cross_val_score
  from keras.models import Sequential
  from keras.layers import Dense
  
  # build a data set
  dataset = pd.DataFrame(randn(100, 2), columns='X1 X2'.split())
  dataset["Y"]=dataset["X1"]+dataset["X2"]
  
  # seperate X and y
  X = dataset.iloc[:, 0:2].values
  Y = dataset.iloc[:, 2].values
  
  # define classifier
  def build_classifier():
      classifier = Sequential()
      classifier.add(Dense(units = 2, kernel_initializer = 'uniform', activation = 'relu', input_dim = 2))
      classifier.add(Dense(units = 1, kernel_initializer = 'uniform', activation = 'sigmoid'))
      classifier.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics = ['accuracy'])
      return classifier
  classifier = KerasClassifier(build_fn = build_classifier, batch_size = 1, epochs = 4)
  
  class testnjob():
      def run():
          accuracies = cross_val_score(estimator = classifier, X = X, y = Y, cv = 5, n_jobs = -1)
          return(accuracies)
  if __name__ == '__main__':
      accuracies = testnjob.run()
  </code></pre>
  
  <p>The error message was:</p>
  
  <pre><code>ImportError: [joblib] Attempting to do parallel computing without protecting
  your import on a system that does not support forking. To use parallel-
  computing in a script, you must protect your main loop using
  "if __name__ == '__main__'". Please see the joblib documentation on Parallel
  for more information
  </code></pre>
  
  <p>The code worked if I set <em>n_jobs=1</em>.</p>
  
  <p>Is there a way to resolve this problem?</p>
  
  <p>Added: The code works on linux virtual machine. I tried with Ubuntu on Virtualbox, anaconda (python 3.6)+ spyder (Tensorflow backend).</p>
  
  <p>Added: I tried the same code in pycharm, a different error message showed up:</p>
  
  <pre><code>AttributeError: Can't get attribute 'build_classifier' on
  &lt;module '__main__' (built-in)&gt;
  </code></pre>
  
  <p>Thank you!</p>