Error in scikit - recognizes LDA function - graphs show non-zero correlation

I made several LDAs using the scikit-learn LDA function, and in my graphs I noticed that there is a non-zero correlation between LDs.

from sklearn.lda import LDA sklearn_lda = LDA(n_components=2) transf_lda = sklearn_lda.fit_transform(X, y) 

This is very important, so I came back and used the Iris dataset as a reference. I also found in the scikit documentation the same non-zero LDA correlation graph that I could reproduce.

Anyway, to give you an overview of what it looks like

  • The plot is in the upper left corner: there is clearly something wrong here.
  • The plot in the lower left corner: this is the source data, not the right approach, but one attempt to replicate scikit resuls
  • Charts in the upper and lower right directions: this is how it should look.

enter image description here

I put the code in IPython notebook if you want to take a look at it and try it for yourself.

The scikit documentation, which is consistent with (incorrect), leads to the top left: http://scikit-learn.org/stable/auto_examples/decomposition/plot_pca_vs_lda.html

LDA in R, which is shown in the lower right: http://tgmstat.wordpress.com/2014/01/15/computing-and-visualizing-lda-in-r/

+7
python scikit-learn r lda
source share
2 answers

There really was an error in the LDA conversion function: the classifier scales were mistakenly applied after the actual conversion. This has been fixed here . Changes have been merged into the master branch, so it should be in version 1.6 of scikit-learn.

+1
source share

Well, now what happens (based on a discussion of GitHub ) is that the LDA in scikit-learn does not have an orthonormal basis.

I want to post this as an answer to close this question now. Thanks for the discussion!

Scikit study

enter image description here

 from sklearn.decomposition import PCA sklearn_pca = PCA(n_components=2) transf_pca = sklearn_pca.fit_transform(transf_lda) 

enter image description here

Step by step approach

And for comparison, here is a step-by-step approach again

enter image description here

0
source share

All Articles