-
Notifications
You must be signed in to change notification settings - Fork 13
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
Additional sampling tests #15
Conversation
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.
These new files are empty; looks like there might've been an issue copying them. Also, there's a typo in one of the file names.
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.
Let's squash these two commits before we continue.
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.
Looks like you need to run black
on this source (e.g. make black
from the project root). That should take care of the formatting issues.
29e60ce
to
1f8bf05
Compare
So far, I convert the test to |
Don't forget to resolve the review comments when you commit/rebase relevant changes! |
f761419
to
5155fce
Compare
To fix the |
With that {'p_0_stickbreaking__': array([0., 0.]),
'p_1_stickbreaking__': array([0., 0.]),
'p_2_stickbreaking__': array([0., 0.]),
'S_t': array([1, 2, 2, 2, 2, 0, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 0, 2, 2, 1, 1,
1, 1, 1, 1, 2, 1, 2, 2, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2,
2, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 1, 1, 1,
1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 2,
2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2,
2, 2, 2, 2, 0, 2, 2, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0,
0, 0, 0, 2, 0, 2, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0,
0, 1]),
'mu_1_log__': array(8.00636757),
'mu_2_log__': array(nan),
'beta_s_log__': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])} Of course, the In summary, it looks like there might be a sign error such that |
Adjusted according to recommendations from @brandonwillard, solved both |
Sampling for seasonality with fixed effect would generate positive Poisson prediction with MAPE around 30%. Percentage of true value falls into predicted 95% CI is also about 30%. Also moved metric checking function into utility. |
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.
Do you know what's causing the FloatingPointError
that's making the tests fail?
b7f6472
to
78ff675
Compare
changed up some formatting issue and added in descriptions for metrics checking function. A not working version of |
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.
Looking at the test errors, it seems like the sampled mu
values might be too large for the exp
in your logp
implementation.
Just adjust logp as requested. and both seasonality and seasonality_ztp is able to pass individual test. but not when call |
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.
Looking at the output, the perform
you're referring to is the Theano Op.perform
for the exp
function. When Theano's C-compilation is turned off/not implemented for an operator, Op.perform
for Theano's exp
operator essentially calls np.exp
on some arguments. The code you're seeing in Op.perform
is doing just that, since self.ufunc
is basically/literally np.exp
.
The actual error is—again—a FloatingPointError
, and Theano's debug output shows you the inputs used by Op.perform
. They're still quite large for exp
.
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.
Try wrapping the pm.sample
in a with np.errstate(over='warn'):
.
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.
Success!
Unfortunately, it says the tests are taking 28 minutes to run! We need to trim that down by a lot.
If pm.sample_posterior_predictive
is the cause, we can remove the steps that rely on it and focus on posterior sample checks alone.
I switched the metrics from posterior estimation to measuring the distance from the real parameters of the distributions. In addition I added in [ Conway-Maxwell-Poission distribution] Additionally, we are able to reduce the time to run the script by removing sampling posterior only to an extent. For tests with seasonality we would still need reasonable amount of time just to train the model. |
This should be in a separate PR. |
post_pred_imps_hpd_df = az.hdi( | ||
az_post_trace, hdi_prob=ci_conf, group="posterior_predictive", var_names=["Y_t"] | ||
).to_dataframe() | ||
|
||
post_pred_imps_hpd_df = post_pred_imps_hpd_df.unstack(level="hdi") | ||
post_pred_imps_hpd_df.columns = post_pred_imps_hpd_df.columns.set_levels( | ||
["upper", "lower"], level="hdi" | ||
) | ||
pred_range = post_pred_imps_hpd_df[positive_index]["Y_t"] |
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.
We can't use the imp
naming scheme—or references to anything like that—in this repository.
Looks like we'll have to resubmit this to the |
Toy series with added time series component.
So far I can only run thru line 180 with no issue.
After 180 when I started to actually sampling the series, there would be errors saying derivatives of the seasonal components prams are zeros.
ValueError: Mass matrix contains zeros on the diagonal. The derivative of RV beta_s_log__.ravel()[0] is zero.
Originally I also attempt with multiple Fourier series and I was able to run thru it. Yet, I think it would make more sense to use fixed effect based on our current data set up.