MatLab PCA-LDA Code

23 views (last 30 days)
Avery Wood
Avery Wood on 22 Nov 2019
Commented: Avery Wood on 22 Nov 2019
I am in need of a PCA-LDA (linear discriminant analysis) code that is fully annotated with a graphical output that shows separation. All the codes I've found on here are not fully annotated or explained. I've worked with PCA, but I'm new to LDA. HELP.

Answers (1)

the cyclist
the cyclist on 22 Nov 2019
If you have the Statistics and Machine Learning Toolbox, then you can use the built-in pca function.
I'm not sure what you mean by "fully annotated". If you are hoping for code that is highly commented and explains what is going on, then you might want to take a look at my answer to this question, where I go into some detail for a simple example, and answer several users' questions.
If you mean you want the PCA components annotated, then maybe the biplot function is useful? Take a look at the examples in the documentation.
Regarding LDA ... you'll need the Text Analytics Toolbox. You could start by taking a look at the fitlda function. I can't help much there, as I don't have the toolbox and I've only done LDA in R.
There are some really good video available on the theory. This lecture by David Blei goes into a lot of depth.
  3 Comments
the cyclist
the cyclist on 22 Nov 2019
Oh, sorry! Looks like that is also in the Stats toolbox, e.g. here. I haven't used it at all.
Avery Wood
Avery Wood on 22 Nov 2019
No worries! I should have clarified more.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!