Skip to content

Conversation

Micky774
Copy link
Contributor

@Micky774 Micky774 commented Mar 4, 2022

Reference Issues/PRs

Resolves #15984

What does this implement/fix? Explain your changes.

PR #15984: Identifies inaccuracy in LDA calculation and implements fix.
This PR: Confirms the correctness of the fix, establishes a new test, and continues discussion/review.

Any other comments?

LDA's SVD solver implements a solution through this formulation, found in Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer:
image

This is backed up by the corresponding MASS implementation for lda in R: https://github.com/cran/MASS/blob/bf02c4405e66def6178eb8c7c13188f82fd2fd54/R/lda.R#L193

I don't really know if this needs a changelog entry, since most results should be unaffected (e.g. current test-suite).

OkonSamuel and others added 4 commits December 28, 2019 11:58
Corrected the 'fac` multiplier in the case of between variance scaling. It really doesn't affect the singular vectors but it should affect the singular values.
added error exception when fitting LinearDiscriminant model with target vector having `n_classes = 1`
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I'm on the fence about raising an error for n_classes=1. I do not think Linear Discriminant Analysis makes much sense with one class, but fitting on class currently works.

In any case, this PR requires a whats new because it is technically a bug fix. Also this requires an entry in "Changed Models" because in principle someone training on the same data may get a different model:

Changed models
--------------

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

Copy link
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @Micky774

@jeremiedbb jeremiedbb merged commit 3110ccf into scikit-learn:main Mar 10, 2022
@Micky774 Micky774 deleted the lda_fac branch March 10, 2022 20:31
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Apr 6, 2022
Co-authored-by: Okon Samuel <39421418+OkonSamuel@users.noreply.github.com>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants