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 is pyagrum.config['learning', 'priorWeight'] (1.0).

Returns:

the learner itself, so that we can chain the calls.

Return type:

pyagrum.ktbn.KTBNLearner

Raises:

pyagrum.OutOfBounds – if weight is 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

KTBNLearner