-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Convert zero-inflated distributions to Mixture subclasses #2231
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
Conversation
* Make spacing more compliant to PEP8 * Raise NotImplementedError from SplineWrapper grad operation Fixes #2209 * Instantiate SplineWrapper recursively to simplify the architecture * Create spline derivatives lazily * Move grad_op to a separate property * Add tests for SplineWrapper * Fix style issues
Update create testenv
* add draft * add draft * move and rename * better docstring * added tests
WIP: replace Hessian scaling guessing by an identity matrix
remaining fix in #2110
pymc3/tests/test_distributions.py
Outdated
@@ -591,6 +591,10 @@ def test_zeroinflatednegativebinomial(self): | |||
self.checkd(ZeroInflatedNegativeBinomial, Nat, | |||
{'mu': Rplusbig, 'alpha': Rplusbig, 'psi': Unit}) | |||
|
|||
def test_zeroinflatedbinomial(self): | |||
self.checkd(ZeroInflatedBinomial, Nat, |
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.
You forgot to import ZeroInflatedBinomial
in the test_distributions.py
Too bad we still haven't figured out how to do this with the Mixture class. |
scaling for NUTS using 'advi_map'
Let me look into it. Might not be worth the overhead just to use |
Actually, its pretty easy. Hold off on merging this for the moment; I will convert all the zero-inflated distributions over and move them to |
Is it? I think we tried it but it wasn't easy to define a 0-distribution. CC @AustinRochford |
Just used a |
And here is zero-inflated binomial. Seems to work. Let me know if I am missing something (I very well could be). |
Please test. |
pymc3/distributions/mixture.py
Outdated
""" | ||
|
||
def __init__(self, psi, theta, *args, **kwargs): | ||
self.theta = theta = tt.as_tensor_variable(theta) |
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.
you should also cast psi
into tensor (same below), although might not necessary after #2233 is merge
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.
That happens in the superclass init (Line 48)
Since these are always 2-component mixtures, I've changed the |
…ion of psi in docstring
Seems to have a problem generating random draws with a multidimensional size. Not sure why. |
Looks good overall. I had similar problems matching |
* Change sample() to use live_plot_kwargs instead of **kwargs. * Pass kwargs of sample to _sample. * Typo wargs -> kwargs. * Re-add kwargs to _sample().
* [WIP] clean up GLM doc * pm.glm.glm -> pm.glm.GLM.from_formula * pm.glm.plot_posterior_predictive -> pm.plot_posterior_predictive_glm * remove find_MAP and used default init * More clean up * more clean up * GLM doc clean up last notebook. change to a slidely different example.
Passing This was the reason for |
Parameters | ||
---------- | ||
psi : float | ||
Expected proportion of Poisson variates (0 < psi < 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.
Should say Binomial
This reverts commit 482e751.
…cast-conditions Don't broadcast conditions in Mixture logp
@fonnesbeck the |
…ion of psi in docstring
…nto zero_inflated_binomial
Well, I rebased instead of merged, so this branch is irrevocably messed up. Closing in favor of #2246 |
Added the ZIB distribution to
discrete.py
, along with tests.