graph_tool.inference.LatentMultigraphBlockState#
- class graph_tool.inference.LatentMultigraphBlockState(g, aE=nan, nested=True, state_args={}, bstate=None, self_loops=False, **kwargs)[source]#
Bases:
UncertainBaseState
Inference state of an erased Poisson multigraph, using the stochastic block model as a prior.
- Parameters:
- g
Graph
Measured graph.
- aE
float
(optional, default:NaN
) Expected total number of edges used in prior. If
NaN
, a flat prior will be used instead.- nested
boolean
(optional, default:True
) If
True
, aNestedBlockState
will be used, otherwiseBlockState
.- state_args
dict
(optional, default:{}
) Arguments to be passed to
NestedBlockState
orBlockState
.- bstate
NestedBlockState
orBlockState
(optional, default:None
) If passed, this will be used to initialize the block state directly.
- self_loopsbool (optional, default:
False
) If
True
, it is assumed that the uncertain graph can contain self-loops.
- g
References
[peixoto-latent-2020]Tiago P. Peixoto, “Latent Poisson models for networks with heterogeneous density”, Phys. Rev. E 102 012309 (2020) DOI: 10.1103/PhysRevE.102.012309 [sci-hub, @tor], arXiv: 2002.07803
Methods
collect_marginal
([g])Collect marginal inferred network during MCMC runs.
Collect marginal latent multigraph during MCMC runs.
copy
(**kwargs)Return a copy of the state.
entropy
([density])Return the entropy, i.e. negative log-likelihood.
Return the underlying block state, which can be either
BlockState
orNestedBlockState
.get_edge_prob
(u, v[, entropy_args, epsilon])Return conditional posterior log-probability of edge \((u,v)\).
get_edges_prob
(elist[, entropy_args, epsilon])Return conditional posterior log-probability of an edge list, with shape \((E,2)\).
Return the current inferred graph.
mcmc_sweep
([r, multiflip])Perform sweeps of a Metropolis-Hastings acceptance-rejection sampling MCMC to sample network partitions and latent edges.
multiflip_mcmc_sweep
(**kwargs)Alias for
mcmc_sweep()
withmultiflip=True
.set_state
(g, w)virtual_add_edge
(u, v[, entropy_args])virtual_remove_edge
(u, v[, entropy_args])- collect_marginal(g=None)#
Collect marginal inferred network during MCMC runs.
- Parameters:
- g
Graph
(optional, default:None
) Previous marginal graph.
- g
- Returns:
- g
Graph
New marginal graph, with internal edge
EdgePropertyMap
"eprob"
, containing the marginal probabilities for each edge.
- g
Notes
The posterior marginal probability of an edge \((i,j)\) is defined as
\[\pi_{ij} = \sum_{\boldsymbol A}A_{ij}P(\boldsymbol A|\boldsymbol D)\]where \(P(\boldsymbol A|\boldsymbol D)\) is the posterior probability given the data.
- collect_marginal_multigraph(g=None)#
Collect marginal latent multigraph during MCMC runs.
- Parameters:
- g
Graph
(optional, default:None
) Previous marginal multigraph.
- g
- Returns:
- g
Graph
New marginal graph, with internal edge
EdgePropertyMap
"w"
and"wcount"
, containing the edge multiplicities and their respective counts.
- g
Notes
The mean posterior marginal multiplicity distribution of a multi-edge \((i,j)\) is defined as
\[\pi_{ij}(w) = \sum_{\boldsymbol G}\delta_{w,G_{ij}}P(\boldsymbol G|\boldsymbol D)\]where \(P(\boldsymbol G|\boldsymbol D)\) is the posterior probability of a multigraph \(\boldsymbol G\) given the data.
- get_block_state()#
Return the underlying block state, which can be either
BlockState
orNestedBlockState
.
- get_edge_prob(u, v, entropy_args={}, epsilon=1e-08)#
Return conditional posterior log-probability of edge \((u,v)\).
- get_edges_prob(elist, entropy_args={}, epsilon=1e-08)#
Return conditional posterior log-probability of an edge list, with shape \((E,2)\).
- get_graph()#
Return the current inferred graph.
- mcmc_sweep(r=0.5, multiflip=True, **kwargs)#
Perform sweeps of a Metropolis-Hastings acceptance-rejection sampling MCMC to sample network partitions and latent edges. The parameter
r
controls the probability with which edge move will be attempted, instead of partition moves. The remaining keyword parameters will be passed tomcmc_sweep()
ormultiflip_mcmc_sweep()
, ifmultiflip=True
.
- multiflip_mcmc_sweep(**kwargs)#
Alias for
mcmc_sweep()
withmultiflip=True
.
- set_state(g, w)#
- virtual_add_edge(u, v, entropy_args={})#
- virtual_remove_edge(u, v, entropy_args={})#