em_infer

Contents

em_infer#

graph_tool.inference.em_infer(state, max_iter=1000, max_e_iter=1, epsilon=0.001, learn_first=False, verbose=False)[source]#

Infer the model parameters and latent variables using the expectation-maximization (EM) algorithm with initial state given by state.

Parameters:
statemodel state

State object, e.g. of type graph_tool.inference.EMBlockState.

max_iterint (optional, default: 1000)

Maximum number of iterations.

max_e_iterint (optional, default: 1)

Maximum number of ‘expectation’ iterations inside the main loop.

epsilonfloat (optional, default: 1e-3)

Convergence criterion.

learn_firstbool (optional, default: False)

If True, the maximization (a.k.a parameter learning) is converged before the main loop is run.

verbosebool (optional, default: True)

If True, convergence information is displayed.

Returns:
deltafloat

The last update delta.

niterint

The total number of iterations.

References

[wiki-EM]

“Expectation–maximization algorithm”, https://en.wikipedia.org/wiki/Expectation%E2%80%93maximization_algorithm

Examples

>>> g = gt.collection.data["polbooks"]
>>> state = gt.EMBlockState(g, B=3)
>>> delta, niter = gt.em_infer(state)
>>> state.draw(pos=g.vp["pos"], output="polbooks_EM_B3.svg")
<...>
../_images/polbooks_EM_B3.svg

“Soft” block partition of a political books network with \(B=3\).#