pyagrum.lib.dynamicBN
dynamic Bayesian Network are a special class of BNs where variables can be subscripted by a (discrete) time. See this notebook.

The purpose of this module is to provide basic tools for dealing with dynamic Bayesian Network (and inference) : modeling, visualisation, inference.
pyagrum.lib.dynamicBN.getTimeSlices(dbn, size=None)
Section titled “pyagrum.lib.dynamicBN.getTimeSlices(dbn, size=None)”Try to correctly represent dBN and 2TBN as an HTML string
- Parameters:
- dbn (pyagrum.BayesNet) – a 2TBN or an unrolled BN
- size (int or str) – size of the fig
pyagrum.lib.dynamicBN.getTimeSlicesRange(dbn)
Section titled “pyagrum.lib.dynamicBN.getTimeSlicesRange(dbn)”get the range and (name,radical) of each variables
- Parameters: dbn (gum.BayesNet) – a 2TBN or an unrolled BN
- Returns: all the timeslice of a dbn : [‘0’,’t’] for a classic 2TBN, range(T) for a classic unrolled BN
- Return type: Dict[str,List[T[str,str]]]
pyagrum.lib.dynamicBN.is2TBN(bn)
Section titled “pyagrum.lib.dynamicBN.is2TBN(bn)”Check if bn is a 2 TimeSlice Bayesian network
- Parameters: bn (pyagrum.BayesNet) – the Bayesian network
- Returns: True if the BN is syntaxically correct to be a 2TBN
- Return type: bool
pyagrum.lib.dynamicBN.plotFollow(lovars, twoTdbn, T, evs)
Section titled “pyagrum.lib.dynamicBN.plotFollow(lovars, twoTdbn, T, evs)”plots modifications of variables in a 2TDN knowing the size of the time window (T) and the evidence on the sequence.
- Parameters:
- lovars – list of variables to follow
- twoTdbn – the two-timeslice dbn
- T – the time range
- evs – observations
pyagrum.lib.dynamicBN.plotFollowUnrolled(lovars, dbn, T, evs, vars_title=None)
Section titled “pyagrum.lib.dynamicBN.plotFollowUnrolled(lovars, dbn, T, evs, vars_title=None)”plot the dynamic evolution of a list of vars with a dBN
- Parameters:
- lovars – list of variables to follow
- dbn – the unrolled dbn
- T – the time range
- evs – observations
- vars_title – string for default or a dictionary with the variable name as key and the respective title as value.
pyagrum.lib.dynamicBN.realNameFrom2TBNname(name, ts)
Section titled “pyagrum.lib.dynamicBN.realNameFrom2TBNname(name, ts)”@return dynamic name from static name and timeslice (no check)
pyagrum.lib.dynamicBN.showTimeSlices(dbn, size=None)
Section titled “pyagrum.lib.dynamicBN.showTimeSlices(dbn, size=None)”Try to correctly display dBN and 2TBN
- Parameters:
- dbn (pyagrum.BayesNet) – a 2TBN or an unrolled BN
- size (int or str) – size of the fig
pyagrum.lib.dynamicBN.unroll2TBN(dbn, nbr)
Section titled “pyagrum.lib.dynamicBN.unroll2TBN(dbn, nbr)”unroll a 2TBN given the nbr of timeslices
- Parameters:
- dbn (pyagrum.BayesNet) – a 2TBN or an unrolled BN
- nbr (int) – the number of timeslice
- Returns: unrolled BN from a 2TBN and the nbr of timeslices
- Return type: pyagrum.BayesNet