inferlo.generic.inference.inference
Functions
|
Inference with (loopy) Belief Propagation. |
|
Inference with Bucket Elimination. |
|
Inference with Bucket Elimination on binary tree. |
|
Inference with Bucket Renormalization. |
|
Calculates marginal probabilities using provided algorithm for computing partition function. |
|
Inference with Iterative Join Graph Propagation. |
|
Inference with Mean Field. |
|
Inference with Mini Bucket Elimination. |
|
Inference with Mini-Bucket Elimination on binary tree. |
|
Inference with Mini-Bucket Renormalization on binary tree. |
|
Inference with Weighted Mini Bucket Elimination. |
- inferlo.generic.inference.inference.belief_propagation(model: GraphModel, max_iter: int = 1000, converge_thr: float = 1e-05, damp_ratio: float = 0.1) InferenceResult [source]
Inference with (loopy) Belief Propagation.
Estimates partition function using Loopy Belief Propagation algorithm.
- Parameters:
model – Model for which to perform inference.
max_iter – Number of iterations.
converge_thr – Convergence threshold.
damp_ratio – Damp ratio.
- Returns:
Inference result.
- References
- inferlo.generic.inference.inference.bucket_elimination(model: GraphModel, elimination_order_method: str = 'random') float [source]
Inference with Bucket Elimination.
Estimates partition function using Bucket Elimination algorithm.
- Parameters:
model – Model for which to perform inference.
elimination_order_method – Elimination order. Can be ‘random’, ‘not_random’ or ‘given’. If ‘given’, elimination order should be passed in ‘elimination_order’ argument.
- Returns:
Natural logarithm of estimated partition function.
- References
[1] Rina Dechter. Bucket elimination: A unifying framework for reasoning. 1999. https://arxiv.org/abs/1302.3572
- inferlo.generic.inference.inference.bucket_elimination_bt(model: GraphModel) InferenceResult [source]
Inference with Bucket Elimination on binary tree.
It runs Bucket elimination multiple times in different order to get marginal probabilities for every variable. However, it partially reuses results using “divide & conquer” technique, which allows to compute all marginal probabilities by doing only O(N logN) eliminations.
- inferlo.generic.inference.inference.bucket_renormalization(model: GraphModel, ibound: int = 10, max_iter: int = 1) float [source]
Inference with Bucket Renormalization.
Estimates partition function using Bucket Renormalization algorithm.
- Parameters:
model – Model for which to perform inference.
ibound – Maximal size of mini-bucket.
max_iter – Number of optimization iterations. 0 corresponds to Mini-Bucket Renormalization. 1 corresponds to Global-Bucket Renormalization. Default is 1.
- Returns:
Natural logarithm of estimated partition function.
- References
[1] Sungsoo Ahn, Michael Chertkov, Adrian Weller, Jinwoo Shin. Bucket Renormalization for Approximate Inference. 2018. https://arxiv.org/abs/1803.05104
- inferlo.generic.inference.inference.get_marginals(model: GenericGraphModel, log_pf_algo: Callable[[GenericGraphModel], float], var_ids: List[int] = None, skip_last: bool = False) InferenceResult [source]
Calculates marginal probabilities using provided algorithm for computing partition function.
For every value of every variable builds new model where value of that variable is fixed, and computes partition function for new model. Then calculates marginal probability.
This is high-level abstraction, agnostic of underlying algorithm. It will get exact results as long as underlying algorithm is exact.
- Parameters:
model – Graphical model.
log_pf_algo – Function which computes.
var_ids – If set, marginal probabilities will be only calculated for these variables.
skip_last – If True, marginal probabilities will be calculated for all but one values of variables, and last value will be inferred from condition that all probabilities add up to 1. This saves computation, but not recommended for approximate algorithms, as it may yield negative values. If False, all marginal probabilities will be computed independently, and then normalized - so they won’t depend on the global partition function.
- inferlo.generic.inference.inference.iterative_join_graph_propagation(model: GraphModel, ibound: int = 10, max_iter: int = 1000, converge_thr: float = 1e-05, damp_ratio: float = 0.1) float [source]
Inference with Iterative Join Graph Propagation.
- Estimates partition function using Iterative Join Graph Propagation
algorithm, which belongs to the class of Generalized Belief Propagation methods.
- Parameters:
model – Model for which to perform inference.
ibound – Maximal size of mini-bucket.
max_iter – Number of iterations.
converge_thr – Convergence threshold.
damp_ratio – Damp ratio.
- Returns:
Natural logarithm of estimated partition function.
- References
[1] Rina Dechter, Kalev Kask, Robert Mateescu. Iterative Join-Graph Propagation. 2012. https://arxiv.org/abs/1301.0564
- inferlo.generic.inference.inference.mean_field(model: GraphModel, max_iter: int = 1000, converge_thr: float = 0.01) float [source]
Inference with Mean Field.
Estimates partition function using Mean Field approximation.
- Parameters:
model – Model for which to perform inference.
max_iter – Maximal number of iterations.
converge_thr – Convergence threshold.
- Returns:
Natural logarithm of estimated partition function.
- References
- inferlo.generic.inference.inference.mini_bucket_elimination(model: GraphModel, ibound: int = 10) float [source]
Inference with Mini Bucket Elimination.
Estimates partition function using Mini Bucket Elimination algorithm.
- Parameters:
model – Model for which to perform inference.
ibound – Maximal size of mini-bucket.
- Returns:
Natural logarithm of estimated partition function.
- References
[1] Rina Dechter, Irina Rish. Mini-buckets: A general scheme for bounded inference. 2003. https://dl.acm.org/doi/abs/10.1145/636865.636866
- inferlo.generic.inference.inference.mini_bucket_elimination_bt(model: GraphModel, ibound: int = 10) InferenceResult [source]
Inference with Mini-Bucket Elimination on binary tree.
- Parameters:
model – Model for which to perform inference.
ibound – Maximal size of mini-bucket.
- inferlo.generic.inference.inference.mini_bucket_renormalization_bt(model: GraphModel, ibound: int = 10) InferenceResult [source]
Inference with Mini-Bucket Renormalization on binary tree.
- Parameters:
model – Model for which to perform inference.
ibound – Maximal size of mini-bucket.
- inferlo.generic.inference.inference.weighted_mini_bucket_elimination(model: GraphModel, ibound: int = 10) float [source]
Inference with Weighted Mini Bucket Elimination.
Estimates partition function using Weighted Mini Bucket Elimination algorithm.
- Parameters:
model – Model for which to perform inference.
ibound – Maximal size of mini-bucket.
- Returns:
Natural logarithm of estimated partition function.
- References
[1] Qiang Liu, Alexander T. Ihler. Bounding the Partition Function using Holder’s Inequality. 2011. [2] Original implementation.