BootstrapMixture.add
- BootstrapMixture.add(name, bn, w=1)
Adds a BN to the model. If the model has no reference BN yet (an empty
pyagrum.bnmixture.BNMixture), a copy of the added BN becomes the reference; adding other BNs does not change it (seepyagrum.bnmixture.BNMixture.updateRef).- Parameters:
name (
str) – Name of the BN to add.bn (
pyagrum.BayesNet) – BN to add.w (
float) – Weight of the BN.
- Raises:
pyagrum.InvalidArgument – If the weight is negative.
pyagrum.InvalidArgument – If the names of the variables in the BN to add are differents from the one in the reference BN.
pyagrum.InvalidArgument – If the variables in the BN to add are differents from the one in the reference BN.
pyagrum.InvalidArgument – If the name in argument is the same as the reference BN’s name.
pyagrum.ArgumentError – If the name in argument already exists for a different BN in the model.
- Return type:
None
Example
import pyagrum as gum
import pyagrum.bnmixture as bnm
mix = bnm.BootstrapMixture("ref", gum.fastBN("A->B->C"))
mix.add("bn1", gum.fastBN("A->B->C"))
mix.add("bn2", gum.fastBN("A->B;A->C"))
mix.add("bn3", gum.fastBN("C->B->A"), w=1)
mix.names()
# ['bn1', 'bn2', 'bn3']
Class