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_iter
int
(optional, default:1000
) Maximum number of iterations.
- max_e_iter
int
(optional, default:1
) Maximum number of ‘expectation’ iterations inside the main loop.
- epsilon
float
(optional, default:1e-3
) Convergence criterion.
- learn_first
bool
(optional, default:False
) If
True
, the maximization (a.k.a parameter learning) is converged before the main loop is run.- verbose
bool
(optional, default:True
) If
True
, convergence information is displayed.
- Returns:
- delta
float
The last update delta.
- niter
int
The total number of iterations.
- delta
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") <...>