pyAgrum.lib.dynamicBN

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

For more details, <https://lip6.fr/Pierre-Henri.Wuillemin/aGrUM/docs/last/notebooks/dynamicBn.ipynb.html>

_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 – the dynamic BN

  • size – size of the fig

pyAgrum.lib.dynamicBN.getTimeSlicesRange(dbn)

get the range and (name,radical) of each variables

Parameters

dbn – a 2TBN or an unrolled BN

Returns

all the timeslice of a dbn

e.g. [‘0’,’t’] for a classic 2TBN range(T) for a classic unrolled BN

pyAgrum.lib.dynamicBN.is2TBN(bn)

Check if bn is a 2 TimeSlice Bayesian network

Parameters

bn – the Bayesian network

Returns

True if the BN is syntaxically correct to be a 2TBN

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 – the dynamic BN

  • size – size of the fig

pyAgrum.lib.dynamicBN.unroll2TBN(dbn, nbr)

unroll a 2TBN given the nbr of timeslices

Parameters
  • dbn – the dBN

  • nbr – the number of timeslice

Returns

unrolled BN from a 2TBN and the nbr of timeslices