title: ValueError: Expected 2D array, got 1D array instead: array=[0.31818181 0.40082645 0.49173555 ... 0.14049587 0.14876033 0.15289256]
body: <pre><code>from sklearn.model_selection import train_test_split
  
  X_train, X_test, y_train, y_test = train_test_split(
          data, target, test_size=0.25, random_state=0)
  from sklearn.model_selection import cross_val_score, KFold
  from scipy.stats import sem
  
  def evaluate_cross_validation(clf, X, y, K):
      # create a k-fold cross validation iterator
      cv = KFold( K , shuffle=True, random_state=0)
      # by default the score used is the one returned by score method of the estimator (accuracy)
      scores = cross_val_score(clf, X, y, cv=cv)
      print (scores)
      print ("Mean score: {0:.3f} (+/-{1:.3f})".format(
          np.mean(scores), sem(scores)))
  evaluate_cross_validation(svc_1, X_train, y_train, 5)
  from sklearn import metrics
  
  def train_and_evaluate(clf, X_train, X_test, y_train, y_test):
  
      clf.fit(X_train, y_train)
  
      print ("Accuracy on training set:")
      print (clf.score(X_train, y_train))
      print ("Accuracy on testing set:")
      print (clf.score(X_test, y_test))
  
      y_pred = clf.predict(X_test)
  
      print ("Classification Report:")
      print (metrics.classification_report(y_test, y_pred))
      print ("Confusion Matrix:")
      print (metrics.confusion_matrix(y_test, y_pred))
  train_and_evaluate(svc_1, X_train, X_test, y_train, y_test)
  
  random_image_button = Button(description="New image!")
  
  def display_face_and_prediction(b):
      index = randint(0, 400)
      face = faces.images[index]
      display_face(face)
      print("this person is smiling: {0}".format(svc_1.predict(faces.data[index, :])==1))
  
  random_image_button.on_click(display_face_and_prediction)
  display(random_image_button)
  display_face_and_prediction(0)
  </code></pre>
  
  <p>when i ran the code beginning from <code>random_image_button = Button(description="New image!")</code>, it gives me the error below:</p>
  
  <blockquote>
    <p>ValueError: Expected 2D array, got 1D array instead: array=[0.31818181
    0.40082645 0.49173555 ... 0.14049587 0.14876033 0.15289256]. Reshape your data either using array.reshape(-1, 1) if your data has a single
    feature or array.reshape(1, -1) if it contains a single sample.</p>
  </blockquote>
  
  <p><strong>How can i fix this?</strong></p>