Skip to content

Inference on mixtures

class pyagrum.bnmixture.BNMixtureInference(bnm, engine=<class ‘pyagrum.pyagrum.LazyPropagation’>)

Section titled “class pyagrum.bnmixture.BNMixtureInference(bnm, engine=<class ‘pyagrum.pyagrum.LazyPropagation’>)”

Class used for inference on BNMixtures.

  • Parameters:
    • bnm (BNM.BNMixture) – Model used.
    • engine (Optional) – Inference tool used to compute inference. You shuold give the class and not an initialized object. Example : engine=pyagrum.LazyPropagation is ok but not engine=pyagrum.LazyPropagation(bnm).

Compute inference for all BNs in the model, excluding reference BN.

  • Parameters: name (str) – Variable to compute posterior for.
  • Returns: The weighted mean (over all the BNs in the model) of the posterior of a variable.
  • Return type: pyagrum.Tensor

Erases all the evidences and apply addEvidence(key,value) for every pairs in evs. Does this for every BN in the model, excluding reference BN.

  • Parameters: evs (dict) – A dict of evidences.

class pyagrum.bnmixture.BootstrapMixtureInference(bnm, engine=<class ‘pyagrum.pyagrum.LazyPropagation’>)

Section titled “class pyagrum.bnmixture.BootstrapMixtureInference(bnm, engine=<class ‘pyagrum.pyagrum.LazyPropagation’>)”

Class used for inference on BootstrapMixture objects. The main difference with BNMixtureInference is that the returned posterior is not a mean of all posteriors in the BNs but only the one of the reference BN. The other BNs are used to estimate parameters such as max, min and quantile values.

  • Parameters:
    • bnm (BNM.BootstrapMixture) – Model used.
    • engine (Optional) – Inference tool used to compute inference. You shold give the class and not an initialized object. Example : engine=pyagrum.LazyPropagation is ok but not engine=pyagrum.LazyPropagation(bnm).

Compute inference for all BNs (including reference BN) in the model.

  • Parameters: name (str) – Variable to compute posterior for.
  • Returns: The posterior of variable name in the reference BN.
  • Return type: pyagrum.Tensor
  • Parameters: name (str) – Variable to compute quantiles for.
  • Returns: Two tensors to store the quantile values. Each tensor stores the quantile for each state of the variable. The values considered are those of the BNs in the Mixture (excluding reference BN).
  • Return type: Tuple[pyagrum.Tensor, pyagrum.Tensor]
  • Raises: pyagrum.SizeError – If the mixture doesn’t contain any BN.

Erases all the evidences and apply addEvidence(key,value) for every pairs in evs. Does this for every BN in the model, including reference BN.

  • Parameters: evs (dict) – A dict of evidences.