KTBNLearner.useSmoothingPrior
- KTBNLearner.useSmoothingPrior(weight=None)
Use a Laplace/BDeu-style smoothing prior.
- Parameters:
weight (
float, optional) – the prior weight, which must not be negative. By default, it ispyagrum.config['learning', 'priorWeight'](1.0).- Returns:
the learner itself, so that we can chain the calls.
- Return type:
- Raises:
pyagrum.OutOfBounds – if
weightis negative.
Example
import pyagrum as gum
import pyagrum.ktbn as ktbn
gum.initRandom(42)
model = ktbn.KTBN.fromBN(gum.fastBN("X0->X1->Y1;Y0"))
ktbn.KTBNDatabaseGenerator(model).drawSamples(50, 10, ".", "traj") # traj1.csv ... traj50.csv
learner = ktbn.KTBNLearner(".", "traj", 50, 2, gum.fastBN("X;Y")) # k=2, variables X and Y
learner.useGreedyHillClimbing()
learner.useSmoothingPrior(0.5)
dict(s[:2] for s in learner.state())["Prior"]
# 'Smoothing'
Class