Skip to content

Conversation

@albertpod
Copy link
Member

This PR adds a new Jupyter notebook demonstrating a complete end-to-end workflow for Bayesian Structured Time Series (BSTS).

The notebook serves as a practical example of:

  1. Dynamic Data Ingestion: Fetching real-time historical and forecast weather data via the Open-Meteo API.
  2. Bayesian Inference: Using a State Space Model to decompose demand into Trend, Seasonality, and Exogenous variables (Temperature/Rain).

@albertpod albertpod marked this pull request as draft November 22, 2025 10:06
@Nimrais
Copy link
Member

Nimrais commented Nov 22, 2025

Very fun example! Good job! I did spend some time trying to make a very similiar model to work.

I see for you prediction rule you use

@rule AugmentedPoisson(:out, Marginalisation) (q_η::GaussianDistributionsFamily,) = begin
    return Poisson(exp(mean(q_η)))
end

In the literature your AugmentedPoisson is called Poisson–lognormal distribution, I found a nice cheatsheet for it https://jchiquet.github.io/assets/talks/pln_semstat_11-22.pdf.

More or less it means in this model you can easily improve your prediction quality changing this rule into

@rule AugmentedPoisson(:out, Marginalisation) (q_η::GaussianDistributionsFamily,) = begin
    _mean = mean(q_η)+ 0.5*var(q_η)
    return Poisson(exp(_mean))
end

@albertpod
Copy link
Member Author

@Nimrais, looks cool! Feel free to file a PR inside this PR with any suggestion!

@albertpod
Copy link
Member Author

albertpod commented Nov 22, 2025

@ismailsenoz I integrated both the Poisson and BinomialPolya code into this notebook, but I think I made some mistakes with the scaling or data pre-processing before feeding it to the model. Consequently, the inference is worse than what we saw previously. Could you take a look?

Main to-dos before merging:

  • Check the narrative and explanations.

  • Fix the inference for the bonus Poisson and BinomialPolya nodes. (@ismailsenoz I can't see the mistake, it worked in script you shared for Poisson, for BinomialPolya, I haven't ran on tacos dataset, but should work imo)

  • Some weird warning when running inference for Poisson and Binomial about constraints.. I don't see why

┌ Warning: Some variables in factorization constraint q(z, z₁, z₂, zprev, F, Q, η, μ, β, s) = q(z, z₁, z₂, zprev, β, η, μ, s)q(F)q(Q) are not present in the context.

  • Rerun the notebook one last time before NeurIPS to get a more up-to-date forecast!

@albertpod albertpod marked this pull request as ready for review November 22, 2025 15:24
@albertpod albertpod merged commit 12c70ff into main Nov 24, 2025
4 checks passed
@albertpod albertpod deleted the sts-dev branch November 24, 2025 19:29
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.

4 participants