beanmachine.ppl.compiler.fix_beta_conjugate_prior module

beanmachine.ppl.compiler.fix_beta_conjugate_prior.beta_bernoulli_conjugate_fixer(bmg: beanmachine.ppl.compiler.bm_graph_builder.BMGraphBuilder) Callable[[beanmachine.ppl.compiler.bmg_nodes.BMGNode], Union[beanmachine.ppl.compiler.bmg_nodes.BMGNode, None, beanmachine.ppl.compiler.fix_problem.NodeFixerError]]

This fixer transforms graphs with Bernoulli likelihood and Beta prior. Since this is a conjugate pair, we analytically update the prior parameters Beta(alpha, beta) using observations to get the posterior parameters Beta(alpha’, beta’). Once we update the parameters, we delete the observed samples from the graph. This greatly decreases the number of nodes, the number of edges in the graph, and the Bayesian update is reduced to parameter update which can lead to performance wins during inference.

beanmachine.ppl.compiler.fix_beta_conjugate_prior.beta_binomial_conjugate_fixer(bmg: beanmachine.ppl.compiler.bm_graph_builder.BMGraphBuilder) Callable[[beanmachine.ppl.compiler.bmg_nodes.BMGNode], Union[beanmachine.ppl.compiler.bmg_nodes.BMGNode, None, beanmachine.ppl.compiler.fix_problem.NodeFixerError]]

This fixer transforms graphs with Binomial likelihood and Beta prior. Since this is a conjugate pair, we analytically update the prior parameters Beta(alpha, beta) using observations to get the posterior parameters Beta(alpha’, beta’). Once we update the parameters, we delete the observed samples from the graph. This greatly decreases the number of nodes, the number of edges in the graph, and the Bayesian update is reduced to parameter update which can lead to performance wins during inference.