pyAgrum.lib.dynamicBN

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

_images/dBN.png

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)

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)

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)

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)

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)

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)

@return dynamic name from static name and timeslice (no check)

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)

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