Hi again,
I'm following the cookbook and I'm collecting vertex marginals during mcmc_equilibrate, so pv = [None] * len(state.get_levels()) def collect_marginals(s): global pv pv = [sl.collect_vertex_marginals(pv[l]) for l, sl in enumerate(s.get_levels())] gt.mcmc_equilibrate(state, force_niter=1000, mcmc_args=dict(niter=10), wait=wait, nbreaks=nbreaks, epsilon=epsilon, callback=collect_marginals ) After this is done, every element of pv will be, basically, a list of arrays with as many elements as many vertexs are at specific level, each with the counts for memberships. In fact, when I need to assign groups to the original vertexs to a blockstate at level L > 0 (say, level 2) I can use state.project_partition(2, 0) the vertex map will contain as many elements as the number of vertex of my graph, each labeled according to the blocks at level 2 of the hierarchy. I cannot find a smart way to project the marginals I've collected, would it be sufficient to sum numbers for pv[0] following the hierarchy (that is, summing counts for all groups at level 0 which are included in the same group at level 2)? Thanks d _______________________________________________ graphtool mailing list [hidden email] https://lists.skewed.de/mailman/listinfo/graphtool 
Administrator

Am 15.01.20 um 18:01 schrieb Davide Cittaro:
> Hi again, > I'm following the cookbook and I'm collecting vertex marginals during mcmc_equilibrate, so > > pv = [None] * len(state.get_levels()) > def collect_marginals(s): > global pv > pv = [sl.collect_vertex_marginals(pv[l]) for l, sl in enumerate(s.get_levels())] > > gt.mcmc_equilibrate(state, force_niter=1000, mcmc_args=dict(niter=10), wait=wait, > nbreaks=nbreaks, epsilon=epsilon, callback=collect_marginals > ) > > After this is done, every element of pv will be, basically, a list of arrays with as many elements as many vertexs are at specific level, each with the counts for memberships. > In fact, when I need to assign groups to the original vertexs to a blockstate at level L > 0 (say, level 2) I can use > > state.project_partition(2, 0) > > the vertex map will contain as many elements as the number of vertex of my graph, each labeled according to the blocks at level 2 of the hierarchy. > I cannot find a smart way to project the marginals I've collected, would it be sufficient to sum numbers for pv[0] following the hierarchy (that is, summing counts for all groups at level 0 which are included in the same group at level 2)? The group labels of the projected state will match the node index of the original level. So you only need to look into the marginal distribution for that level, and copy it to the base level.  Tiago de Paula Peixoto <[hidden email]> _______________________________________________ graphtool mailing list [hidden email] https://lists.skewed.de/mailman/listinfo/graphtool

Tiago de Paula Peixoto <tiago@skewed.de> 
> On 16 Jan 2020, at 10:46, Tiago de Paula Peixoto <[hidden email]> wrote: > > The group labels of the projected state will match the node index of the > original level. So you only need to look into the marginal distribution > for that level, and copy it to the base level. Excellent, thanks! d _______________________________________________ graphtool mailing list [hidden email] https://lists.skewed.de/mailman/listinfo/graphtool 
Free forum by Nabble  Edit this page 