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

Skip to content

Conversation

dherrera1911
Copy link

@dherrera1911 dherrera1911 commented Sep 5, 2025

Reference Issues/PRs

Partially fixes Issue #23162

What does this implement/fix? Explain your changes.

Background:

The output of the covariance.MinCovDet estimator is strongly biased (see Issue #23162), because it is lacking a consistency correction. This PR adds the missing correction, reducing the bias. In my comment to the Issue, I explain the problem and show that this PR generates less biased output.

Changes:

I added the function _consistency_correction to compute the multiplicative consistency factor, and use it to correct the robust covariance estimate here.

Also, the correction is also needed in another place of the code. The original implementation used an adhoc correction from the original paper, which I substituted for the correction factor obtained with _consistency_correction
here. This change increases code consistency, and the new correction is more theoretically grounded.

Any other comments?

The estimate is still slightly biased because it lacks a finite sample correction. This should be added in the future, for which the MinCovDet implementation in R can be used as a template https://rdrr.io/cran/robustbase/src/R/covMcd.R.

Copy link

github-actions bot commented Sep 5, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: e938beb. Link to the linter CI: here

@dherrera1911 dherrera1911 changed the title Add correction to MinCovDet Add consistency correction to MinCovDet, to reduce bias Sep 5, 2025
@dherrera1911 dherrera1911 changed the title Add consistency correction to MinCovDet, to reduce bias Add consistency correction to covariance.MinCovDet, to reduce bias Sep 5, 2025
@dherrera1911 dherrera1911 changed the title Add consistency correction to covariance.MinCovDet, to reduce bias FIX Reduce bias of covariance.MinCovDet with consistency correction Sep 6, 2025
@dherrera1911 dherrera1911 changed the title FIX Reduce bias of covariance.MinCovDet with consistency correction FIX: Reduce bias of covariance.MinCovDet with consistency correction Sep 6, 2025
@dherrera1911
Copy link
Author

dherrera1911 commented Sep 6, 2025

In some cases, this test fails under the new implementation: https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/covariance/tests/test_robust_covariance.py#L35.

The specific test that fails has a much lower tolerance threshold than the other tests of this function, so I suggest increasing the threshold.

In the example code of the Issue #23162 it is shown that the new implementation is much less biased than the original implementation. The test failure should not be blamed on the new implementation, but rather on the variability of the results + low threshold for that specific test.

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.

1 participant