CredalNet.lagrangeNormalization

CredalNet.lagrangeNormalization()

Laplace smoothing of the counts of a BayesNet storing counts of events, such that no probability is 0.

Use this method when using a single BayesNet storing counts of events: for each configuration of the parents where a count is 0, 1 is added to all the counts of the configuration (the other configurations are unchanged). This call is irreversible and modifies the counts stored by the original network.

Does not compute the parameters but keeps the smoothed counts only. Call idmLearning to compute the probabilities (with any parameter value).

Raises:

pyagrum.OperationNotAllowed – If the network contains probabilities instead of counts.

Return type:

None

Example

import pyagrum as gum

bn = gum.fastBN("A->B")
bn.cpt("A").fillWith([0, 10])  # counts of events, with a zero
bn.cpt("B")[:] = [[0, 4], [5, 5]]
cn = gum.CredalNet(bn)
cn.lagrangeNormalization()
cn.idmLearning(0)
[round(p, 4) for p in cn.credalNet_currentCpt()[bn.idFromName("A")][0][0]]
# [0.0833, 0.9167]

Class

CredalNet