Probabilistic Programming in Python: Bayesian Modeling and Probabilistic Machine Learning with Theano
Agent Success
Agent success rate when using this tile
68%
Improvement
Agent success rate improvement when using this tile compared to baseline
0.94x
Baseline
Agent success rate without this tile
72%
Build a small probabilistic model for weekly sales across multiple stores that uses labeled dimensions for stores and weeks, and keeps observed data replaceable without rebuilding the model.
The model must accept:
coords mapping containing store identifiers and week numbers.observed mapping containing sales and price arrays shaped by those coordinates, plus an optional boolean promo array of the same shape.@generates
from typing import Any, Mapping, Sequence
ArrayLike = Any
def build_model(coords: Mapping[str, Sequence[str] | Sequence[int]], observed: Mapping[str, ArrayLike]) -> Any:
"""
Creates and returns the probabilistic model for store-week sales using labeled dimensions and shared data containers.
"""
def sample_posterior(model: Any, draws: int = 500, tune: int = 500, seed: int | None = None) -> Any:
"""
Runs posterior sampling on the provided model and returns the inference results.
"""
def update_observed(model: Any, new_observed: Mapping[str, ArrayLike]) -> None:
"""
Replaces the observed data in the existing model using the mutable data containers while preserving labeled coordinates.
"""
def posterior_predictive(model: Any, trace: Any, samples: int = 300) -> Any:
"""
Generates posterior predictive draws using the latest observed data already bound to the model.
"""Probabilistic programming library with labeled dimension and shared data utilities.
docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10