title: Gaussian NB vs LDA in scikit learn
body: <p>From my understanding, if we only have one feature, then Gaussian NB (naive bayes classification) and LDA (Linear Discriminant Analysis) should give the same result.</p>
  <p>But I didn't succeed with scikit learn.</p>
  <p>First I generate some toy data</p>
  <pre><code>from sklearn.datasets import make_blobs
  X, y = make_blobs(n_samples=20, centers=2, n_features=1,
                    random_state=0)
  </code></pre>
  <p>Then I create a NB model with Gaussian distribution</p>
  <pre><code>from sklearn.naive_bayes import GaussianNB
  gnb = GaussianNB()
  gnb.fit(X, y)
  </code></pre>
  <p>Then a LDA model</p>
  <pre><code>from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
  lda = LinearDiscriminantAnalysis()
  lda.fit(X, y)
  </code></pre>
  <p>Now it is possible to plot the results.</p>
  <pre><code>plt.scatter(X,y)
  X_test = np.linspace(-1, 8, 300).reshape(-1,1)
  
  plt.plot(X_test, gnb.predict_proba(X_test.reshape(-1,1))[:,1],color=&quot;black&quot;)
  plt.plot(X_test, lda.predict_proba(X_test.reshape(-1,1))[:,1],color=&quot;green&quot;)
  
  plt.ylabel('y')
  plt.xlabel('X')
  
  plt.axhline(.5, color='.5')
  plt.show()
  </code></pre>
  <p>But I got the following plot</p>
  <p><a href="https://i.stack.imgur.com/v0fhb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v0fhb.png" alt="enter image description here" /></a></p>
  <p>Maybe I didn't these algorithms. Could you explain why the differences?</p>