BNLearner.useEMWithDiffCriterion
- BNLearner.useEMWithDiffCriterion(epsilon, noise=None)
Enforces that EM with the log-likelihood min difference criterion will be used for parameter learning whenever the dataset contains missing values.
- Parameters:
epsilon (
float) – epsilon sets the approximation stopping criterion: EM stops whenever the difference between two consecutive log-likelihoods drops below epsilon (the min evolution rate criterion is disabled). Note that epsilon should be strictly positive.noise (
float, optional) – During EM’s initialization, the CPTs are randomly perturbed using the following formula: new_CPT = (1-noise) * CPT + noise * random_CPT. Parameter noise must belong to interval [0,1]. By default, noise is given bypyagrum.config['learning', 'emNoise'](0.1).
- Returns:
the BNLearner itself, so that we can chain useXXX() methods.
- Return type:
- Raises:
pyagrum.OutOfBounds – if
epsilonis not strictly positive or ifnoisedoes not belong to interval [0,1].
Example
import pyagrum as gum
with open("data.csv", "w") as f: # "?" is a missing value
f.write("A,B\n" + "0,0\n0,1\n1,1\n1,1\n?,0\n1,?\n" * 20)
learner = gum.BNLearner("data.csv")
learner.useEMWithDiffCriterion(1e-3, 0.0) # no random noise at initialization
bn = learner.learnParameters(gum.fastDAG("A->B"))
learner.EMisEnabledEpsilon(), learner.EMEpsilon()
# (True, 0.001)
Class