Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX Correct LDA fac multiplier - #22696

Merged
jeremiedbb merged 13 commits into
scikit-learn:mainfrom
Micky774:lda_fac
Mar 10, 2022
Merged

FIX Correct LDA fac multiplier#22696
jeremiedbb merged 13 commits into
scikit-learn:mainfrom
Micky774:lda_fac

Conversation

@Micky774

@Micky774 Micky774 commented Mar 4, 2022

Copy link
Copy Markdown
Contributor

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`

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

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
--------------

Comment thread sklearn/discriminant_analysis.py Outdated
Comment thread sklearn/discriminant_analysis.py Outdated

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Otherwise LGTM

Comment thread doc/whats_new/v1.1.rst Outdated
Comment thread doc/whats_new/v1.1.rst Outdated
Comment thread sklearn/discriminant_analysis.py Outdated

@jeremiedbb jeremiedbb left a comment

Copy link
Copy Markdown
Member

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 <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]>
Co-authored-by: Jérémie du Boisberranger <[email protected]>
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