title: How to plot the decision boundary of logistic regression in scikit learn
body: <p>I am trying to plot the decision boundary of logistic regression in scikit learn</p>
  
  <pre><code>features_train_df :  650 columns, 5250 rows
  features_test_df : 650 columns, 1750 rows
  class_train_df = 1 column (class to be predicted), 5250 rows
  class_test_df = 1 column (class to be predicted), 1750 rows
  </code></pre>
  
  <p>classifier code;</p>
  
  <pre><code>tuned_logreg = LogisticRegression(penalty =  'l2', tol =  0.0001,C =  0.1,max_iter =  100,class_weight = "balanced")
  tuned_logreg.fit(x_train[sorted_important_features_list[0:650]].values, y_train['loss'].values)
  y_pred_3 = tuned_logreg.predict(x_test[sorted_important_features_list[0:650]].values)
  </code></pre>
  
  <p>I am getting the correct output for the classifier code.</p>
  
  <p>Got this code online:</p>
  
  <pre><code>code:
  
  X = features_train_df.values
  # evenly sampled points
  x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
  y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
  xx, yy = np.meshgrid(np.linspace(x_min, x_max, 50),
                   np.linspace(y_min, y_max, 50))
  plt.xlim(xx.min(), xx.max())
  plt.ylim(yy.min(), yy.max())
  
  #plot background colors
  ax = plt.gca()
  Z = tuned_logreg.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]
  Z = Z.reshape(xx.shape)
  cs = ax.contourf(xx, yy, Z, cmap='RdBu', alpha=.5)
  cs2 = ax.contour(xx, yy, Z, cmap='RdBu', alpha=.5)
  plt.clabel(cs2, fmt = '%2.1f', colors = 'k', fontsize=14)
  
  # Plot the points
  ax.plot(Xtrain[ytrain == 0, 0], Xtrain[ytrain == 0, 1], 'ro', label='Class 1')
  ax.plot(Xtrain[ytrain == 1, 0], Xtrain[ytrain == 1, 1], 'bo', label='Class 2')
  
  # make legend
  plt.legend(loc='upper left', scatterpoints=1, numpoints=1)
  </code></pre>
  
  <p>error:</p>
  
  <pre><code> ValueError: X has 2 features per sample; expecting 650
  </code></pre>
  
  <p>Please suggest me on where am I going wrong</p>