-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
Refactor terms #582
Refactor terms #582
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov Report
@@ Coverage Diff @@
## main #582 +/- ##
==========================================
- Coverage 87.23% 85.48% -1.76%
==========================================
Files 29 36 +7
Lines 2429 2859 +430
==========================================
+ Hits 2119 2444 +325
- Misses 310 415 +105
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I've run all the examples and they work well. Just updated a couple of them to fix some latex issues. Will merge after test suit finishes. |
Generally speaking, this PR aims to make Bambi internals more modular and extensible. To do that, I removed any logic specific to a given object from another given object. For example, there was Family-specific logic within response terms or the PyMC backend. See
bambi/bambi/terms.py
Lines 52 to 57 in e1503d2
bambi/bambi/terms.py
Lines 65 to 77 in e1503d2
bambi/bambi/backend/pymc.py
Lines 213 to 214 in e1503d2
bambi/bambi/backend/terms.py
Lines 273 to 295 in e1503d2
This approach has been working so far, but if we plan to extend Bambi according to #544 without making it messier, we should stop handling specific cases in the same way we've been doing so far.
In addition, I implemented a couple of extra features/improvements that I'm going to describe below.
Refactor
terms.py
module to its own directory, calledterms
.BaseTerm
class.Features/improvements
softmax
function fromaesara
is now called withaxis=-1
. There's a warning saying that one needs to call it explicitly in the future. I opened Make it possible to pass arguments to link functions in PyMC backend #574 because of this. This PR fixes it, and I don't see the need to handle more general use cases.Likelihood
class now accepts custom distribution functions. Until now, what users could do was pass the name of a distribution that would be looked up in the PyMC namespace (here and here). Now, you can create aLikelihood
instance with a customdist
that will be used as the likelihood function. See here and here.