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 (
BayesNet) – a 2TBN or an unrolled BN - size (
str|None) – size of the fig
- dbn (
- Return type:
str
pyagrum.lib.dynamicBN.getTimeSlicesRange(dbn)
Section titled “pyagrum.lib.dynamicBN.getTimeSlicesRange(dbn)”get the range and (name,radical) of each variables
- Parameters:
dbn (
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[tuple[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 (
BayesNet) – the Bayesian network - Returns: True if the BN is syntaxically correct to be a 2TBN
- Return type:
tuple[bool,str]
pyagrum.lib.dynamicBN.plotFollow(lovars, twoTdbn, T, evs)
Section titled “pyagrum.lib.dynamicBN.plotFollow(lovars, twoTdbn, T, evs)”Plot modifications of variables in a 2TBN knowing the size of the time window (T) and the evidence on the sequence.
- Parameters:
- lovars (
list[str]) – List of variables to follow. - twoTdbn (
BayesNet) – The two-timeslice dBN. - T (
int) – The time range. - evs (
dict) – Observations.
- lovars (
- Return type:
None
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[str]) – List of variables to follow. - dbn (
BayesNet) – The unrolled dBN. - T (
int) – The time range. - evs (
dict) – Observations. - vars_title (
list[str] |None) – String for default title or a dictionary with the variable name as key and its title as value.
- lovars (
- Return type:
None
pyagrum.lib.dynamicBN.realNameFrom2TBNname(name, ts)
Section titled “pyagrum.lib.dynamicBN.realNameFrom2TBNname(name, ts)”- Returns: The dynamic name from static name and timeslice (no check).
- Return type:
str - Parameters:
- name (
str) - ts (
int)
- name (
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 (
BayesNet) – a 2TBN or an unrolled BN - size (
str|None) – size of the fig
- dbn (
- Return type:
None
pyagrum.lib.dynamicBN.unroll2TBN(dbn, nbr)
Section titled “pyagrum.lib.dynamicBN.unroll2TBN(dbn, nbr)”unroll a 2TBN given the nbr of timeslices