-
Notifications
You must be signed in to change notification settings - Fork 77
[ENH] zero-inflated distribution #648
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
base: main
Are you sure you want to change the base?
Conversation
f6ac48c to
7a3d255
Compare
fkiraly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice!
Could we please move the modifications to TruncatedDistribution to another PR, since I think there is some discussion to be had about how to parameterize the options, e.g., why only lower inclusive and not upper inclusive, etc.
The zero inflated distribution looks good.
|
This can now be re-reviewed as #667 is merged |
|
@fkiraly, just bringing this to your attention this needs a review. Thanks! |
| def _truncated_distribution(self) -> TruncatedDistribution: | ||
| # TODO: return self.distribution if it is naturally non-negative. | ||
| # requires support tag (check #244) | ||
| if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is unintuitive behaviour, in a case where distribution already is a TruncatedDistribution, with a lower` of 1, say. IT gets replaced by double wrapped truncation.
I would suggest to consider not manually truncating, but merely suggesting to the user that distribution is non-negative.
Then we do not need to take care of too many modificiation cases that are too hard to explain.
| index=None, | ||
| columns=None, | ||
| ): | ||
| if isinstance(p, np.ndarray) and p.ndim == 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would advise to make p broadcastable, by using the broadcast tags. Then you do not need to handle it manually.
fkiraly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
Two main comments above:
- make
puse the broadcast logic built into the base class, instead of replacing that with a different logic. That way it is consistent. - I would also avoid truncating, actually. I would treat the distribution as a special mixture, instead, this also reduces hard to track case distinctions.
Reference Issues/PRs
Partially towards #554
Blocked by #667What does this implement/fix? Explain your changes.
Adds support for Zero-inflated distribution
Does your contribution introduce a new dependency? If yes, which one?
No.
What should a reviewer concentrate their feedback on?
Design decision of making the lower bound inclusive intruncated.pyDid you add any tests for the change?
No
Any other comments?
After the ZeroInflated implementation is reviewed, I plan to add
ZeroInflatedPoissonandZeroInflatedNegativeBinomialas well using_DelegatedDistributionPR checklist
For all contributions
How to: add yourself to the all-contributors file in the
skproroot directory (not theCONTRIBUTORS.md). Common badges:code- fixing a bug, or adding code logic.doc- writing or improving documentation or docstrings.bug- reporting or diagnosing a bug (get this pluscodeif you also fixed the bug in the PR).maintenance- CI, test framework, release.See here for full badge reference
For new estimators
docs/source/api_reference/taskname.rst, follow the pattern.Examplessection.python_dependenciestag and ensureddependency isolation, see the estimator dependencies guide.