Skip to content

[WIP] variance in f_regression is forced to be positive - #21360

Closed
arnaualba wants to merge 1 commit into
scikit-learn:mainfrom
arnaualba:f_regression_negative_variance
Closed

arnaualba wants to merge 1 commit into
scikit-learn:mainfrom
arnaualba:f_regression_negative_variance

Conversation

@arnaualba

@arnaualba arnaualba commented Oct 18, 2021 •

Copy link
Copy Markdown

Reference Issues/PRs

Closes #11395

What does this implement/fix? Explain your changes.

When the variance of a feature in a dataset is zero, f_regression computes the variance and sometimes gets small (machine precision) negative values instead of zero. This throws an error when the sqrt of the variance is computed.

Any other comments?

Still missing a regression test.
Still needs to be tested with current regression tests

@arnaualba arnaualba changed the title [WIP] f_regression now takes absolute of variance, to avoid small (machine … [MRG] f_regression now takes absolute of variance, to avoid small (machine … Oct 18, 2021
@arnaualba arnaualba changed the title [MRG] f_regression now takes absolute of variance, to avoid small (machine … [MRG] variance in f_regression is forced to be positive Oct 18, 2021
@arnaualba arnaualba changed the title [MRG] variance in f_regression is forced to be positive [WIP] variance in f_regression is forced to be positive Oct 18, 2021
@agramfort

Copy link
Copy Markdown
Member

this is one option but otherwise maybe rely on the mean_variance_axis function in utils/sparsefuncs.py ?

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.

f_regression takes square root of negative values when constant columns are present

2 participants