Skip to content

TIME SERIES Add air passengers notebook #183

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

Merged
merged 3 commits into from
Jun 28, 2021

Conversation

MarcoGorelli
Copy link
Contributor

@MarcoGorelli MarcoGorelli commented Jun 20, 2021

Description

Addresses issue #xxx and aims to advance it to


There's relatively few time series notebooks, so here's one I've put together. It shows how to create a Prophet-like model for the air passengers dataset, with prior and posterior predictive checks

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

almostmeenal commented on 2021-06-21T14:18:02Z
----------------------------------------------------------------

*We could fit this using the model Prophet

(would make more sense grammatically, this is a nitpick feel free to ignore)


@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

almostmeenal commented on 2021-06-21T14:18:02Z
----------------------------------------------------------------

Line #1.    df.plot.scatter(x="Month", y="#Passengers", color="k");

i might be absolutely wrong, but i think pymc3 has a certain color schemes followed in the documentation or something, just check that once, maybe C1 or something is used


@review-notebook-app
Copy link

review-notebook-app bot commented Jun 21, 2021

View / edit / reply to this conversation on ReviewNB

almostmeenal commented on 2021-06-21T14:18:03Z
----------------------------------------------------------------

not sure but maybe these operations can be done in xarray


@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

almostmeenal commented on 2021-06-21T14:18:04Z
----------------------------------------------------------------

Line #21.        df["Month"], _sample(linear_prior_predictive["trend"], 100).T * y_max, color="blue", alpha=0.05

again not sure, but these plots can be generated in arviz maybe, @OriolAbril would you know something about this?


@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

almostmeenal commented on 2021-06-21T14:18:04Z
----------------------------------------------------------------

Line #7.        }

again might be able to do this with xarray, pandas works too, but i think xarray can be a pymc model inferencedata format too so it might be useful, perhaps other people can offer more perspective


@review-notebook-app
Copy link

review-notebook-app bot commented Jun 21, 2021

View / edit / reply to this conversation on ReviewNB

almostmeenal commented on 2021-06-21T14:18:05Z
----------------------------------------------------------------

Line #13.    with linear_with_seasonality:

ive seen this in other examples too, maybe we dont need to call linear_with_seasonality again, pm.sample could happen directly so yeah


MarcoGorelli commented on 2021-06-22T20:10:45Z
----------------------------------------------------------------

I think the alternative here would be

pm.sample_prior_predictive(model=linear_with_seasonality)

but I think using a context manager (with linear_with_seasonality) is more idiomatic to PyMC3 - happy to change if you disagree though, is this what you meant?

@MarcoGorelli
Copy link
Contributor Author

Thanks for your review @almostmeenal ! Sure, I'll revise xarray and see where I can use it!

Copy link
Contributor Author

I think the alternative here would be

pm.sample_prior_predictive(model=linear_with_seasonality)

but I think using a context manager (with linear_with_seasonality) is more idiomatic to PyMC3 - happy to change if you disagree though, is this what you meant?


View entire conversation on ReviewNB

@review-notebook-app
Copy link

review-notebook-app bot commented Jun 22, 2021

View / edit / reply to this conversation on ReviewNB

twiecki commented on 2021-06-22T21:11:27Z
----------------------------------------------------------------

don't need to set the with-context twice in a row.


@review-notebook-app
Copy link

review-notebook-app bot commented Jun 22, 2021

View / edit / reply to this conversation on ReviewNB

twiecki commented on 2021-06-22T21:11:28Z
----------------------------------------------------------------

Here I would link to the reference packages: https://github.com/MBrouns/timeseers and https://github.com/luke14free/pm-prophet (although this one seems abandoned).


@MarcoGorelli
Copy link
Contributor Author

Thanks @twiecki , have updated

i think pymc3 has a certain color schemes followed in the documentation or something

@almostmeenal do you know where these conventions are laid out? I didn't see anything about colours in the [jupyter style guide](https://github.com/pymc-devs/pymc3/wiki/PyMC3-Jupyter-Notebook-Style-Guide

@mjhajharia
Copy link
Member

Thanks @twiecki , have updated

i think pymc3 has a certain color schemes followed in the documentation or something

@almostmeenal do you know where these conventions are laid out? I didn't see anything about colours in the [jupyter style guide](https://github.com/pymc-devs/pymc3/wiki/PyMC3-Jupyter-Notebook-Style-Guide

hi @MarcoGorelli i'm so sorry about getting back so late, so idk if there's a formal convention, but i think pymc documentation follows this consistent pattern of using C0 C1 colors, i heard about it in this issue, while making some interpolated plot. pymc-devs/pymc#3859 (comment)
although im not sure if it is relevant for notebooks or not. its a very minor styling nitpick so nothing to fret about ofcourse

@mjhajharia
Copy link
Member

I think the alternative here would be

pm.sample_prior_predictive(model=linear_with_seasonality)

but I think using a context manager (with linear_with_seasonality) is more idiomatic to PyMC3 - happy to change if you disagree though, is this what you meant?

View entire conversation on ReviewNB

this works!! again, this is a great and useful notebook!! thankyou for putting in all this work!!!

@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

ricardoV94 commented on 2021-06-26T07:49:04Z
----------------------------------------------------------------

About the "multiplicative seasonality": maybe explain in a couple of words. Sounds a bit jargony to me


@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

ricardoV94 commented on 2021-06-26T07:49:05Z
----------------------------------------------------------------

A couple of words about what is this "matrix of Fourier features"?


@review-notebook-app
Copy link

review-notebook-app bot commented Jun 26, 2021

View / edit / reply to this conversation on ReviewNB

ricardoV94 commented on 2021-06-26T07:49:06Z
----------------------------------------------------------------

For the last plot, you could show the time detrended data to more clearly illustrate how the seasonality variation differs between the prior and the data (and similarly for the next plot with the tighter priors)

@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

ricardoV94 commented on 2021-06-26T07:53:02Z
----------------------------------------------------------------

Show the empirircal raw percent change in the last plot, to compare with the model predictions?


@twiecki twiecki merged commit 66b69c6 into pymc-devs:main Jun 28, 2021
@twiecki
Copy link
Member

twiecki commented Jun 28, 2021

This is a good one, thanks @MarcoGorelli!

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.

3 participants