Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Fix residual scale estimation in DoubleResidual #503

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

meh2135
Copy link

@meh2135 meh2135 commented Dec 6, 2024

Reference Issues/PRs

Fixes #492

What does this implement/fix? Explain your changes.

Changes to ResidualDouble:

  • Fixes the method of moments estimation of scale parameters for all supported distributions with finite moments where residual_trafo is absolute or squared
  • Adds warnings when residual_trafo is an arbitrary transform
  • Adds warnings for cauchy and t with df <=2 (no first moment, and no second moment respectively)
  • Adds sample weight support

Does your contribution introduce a new dependency? If yes, which one?

no

What should a reviewer concentrate their feedback on?

  • My added test
  • Added warnings
  • anything around sample_weights

Did you add any tests for the change?

Added tests to confirm uniform quantiles for held out data when the model is correctly specified.

Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Nice!

Would you like a review right now, or is this still a work-in-progress draft?

Some comments:

  • we should not change the core interface in the same pull request as changes to estimators. Your idea of adding a sample_weight arg is great, but we should deal with this separately, to avoid interaction between the changes!
  • changes to the residual estimator look good and sensible. I will have to sit down and work out the math to check, but superficially fine.

@@ -72,7 +72,7 @@ def __rmul__(self, other):
else:
return NotImplemented

def fit(self, X, y, C=None):
def fit(self, X, y, C=None, sample_weight=None):
Copy link
Collaborator

@fkiraly fkiraly Dec 10, 2024

Choose a reason for hiding this comment

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

as said, good idea, but should be in a separate PR. Could you also open an issue to track adding sample weights?

What we should do (please copy this recommendation in an issue):

  • add a tag capability:sample_weight that tells the user whether the weights are used non-trivially
  • add tests in TestAllRegressors that actually passes sample weights, to see that nothing breaks. In particular, nothing should break for any estimator when passed, the current boilerplate would lead to most estimators breaking, as the argument is passed on to _fit!
  • in particular, the boilerplate should check the tag, and pass sample_weight on to _fit only if the tag has value True.
  • in the tests, we should check that _fit does have the arg sample_weight if the tag is set True.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] ResidualDouble regressor does not handle transforms correctly.
2 participants