title: How to get eigenvectors from Linear Discriminant Analysis with scikit-learn
body: <p>How can one obtain the change-of-basis matrix from a scikit-learn linear discriminant analysis object?</p>
  
  <p>For an array <code>X</code> with shape <code>m x p</code> (<code>m</code> samples and <code>p</code> features) and <code>N</code> classes, the scaling matrix has <code>p</code> rows and <code>N-1</code> columns. This matrix can be used to transform the data from the original space to the linear subspace.</p>
  
  <hr>
  
  <p>EDITED after Arya's answer:</p>
  
  <p>Let's consider the following example:</p>
  
  <pre><code>from sklearn.datasets import make_blobs
  from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
  
  X, label = make_blobs(n_samples=100, n_features=2, centers=5, cluster_std=0.10, random_state=0)
  lda = LDA()
  Xlda = lda.fit(X, label)
  Xlda.scalings_
  #array([[ 7.35157288,  6.76874473],
  #       [-6.45391558,  7.97604449]])
  Xlda.scalings_.shape
  #(2, 2)
  </code></pre>
  
  <p>I would expect the scalings_ matrix shape to be (2,4) as I have 2 features and the LDA would provide 5-1 components.</p>