PartitionModeState#

class graph_tool.inference.PartitionModeState(bs, relabel=True, nested=False, converge=False, **kwargs)[source]#

Bases: object

The random label model state for a set of labelled partitions, which attempts to align them with a common group labelling.

Parameters:
bslist of iterables

List of partitions to be aligned. If nested=True, these should be hierarchical partitions, composed each as a list of partitions.

relabelbool (optional, default: True)

If True, an initial alignment of the partitions will be attempted during instantiation, otherwise they will be incorporated as they are.

nestedbool (optional, default: False)

If True, the partitions will be assumed to be hierarchical.

convergebool (optional, default: False)

If True, the label alignment will be iterated until convergence upon initialization (otherwise replace_partitions() needs to be called repeatedly).

References

[peixoto-revealing-2021]

Tiago P. Peixoto, “Revealing consensus and dissensus between network partitions”, Phys. Rev. X 11 021003 (2021) DOI: 10.1103/PhysRevX.11.021003 [sci-hub, @tor], arXiv: 2005.13977

Methods

add_partition(b[, relabel])

Adds partition b to the ensemble, after relabelling it if relabel=True, and returns its index in the population.

align_mode(mode)

Relabel entire ensemble to align with another ensemble given by mode, which should be an instance of PartitionModeState.

copy([bs])

Copies the state.

get_B()

Return the total number of labels used.

get_M()

Return the number of partitions

get_coupled_state()

Return the instance of PartitionModeState representing the model at the upper hierarchical level.

get_marginal(g)

Return a VertexPropertyMap for Graph g, with vector<int> values containing the marginal group membership counts for each node.

get_max(g)

Return a VertexPropertyMap for Graph g, with int values containing the maximum marginal group membership for each node.

get_max_nested()

Return a hierarchical partition as a list of numpy.ndarray objects, containing the maximum marginal group membership for each node in every level.

get_nested_partition(i)

Returns nested partition with index i.

get_nested_partitions()

Returns all nested partitions.

get_partition(i)

Returns partition with index i.

get_partitions()

Returns all partitions.

posterior_cdev([MLE])

Return the uncertainty of the mode in the range \([0,1]\), using maximum likelihood estimates for the marginal node probabilities if `MLE=True`, otherwise using posterior mean estimates.

posterior_entropy([MLE])

Return the entropy of the random label model, using maximum likelihood estimates for the marginal node probabilities if `MLE=True`, otherwise using posterior mean estimates.

posterior_lprob(b[, MLE])

Return the log-probability of partition b, using maximum likelihood estimates for the marginal node probabilities if `MLE=True`, otherwise using posterior mean estimates.

relabel()

Re-order group labels according to group sizes.

relabel_partition(b)

Returns a relabelled copy of partition b, according to its alignment with the ensemble.

remove_partition(i)

Removes partition with index i from the ensemble.

replace_partitions()

Removes and re-adds every partition, after relabelling, and returns the entropy difference (negative log probability).

sample_nested_partition([MLE, fix_empty])

Sampled a nested partition from the inferred model, using maximum likelihood estimates for the marginal node probabilities if `MLE=True`, otherwise using posterior mean estimates.

sample_partition([MLE])

Sampled a partition from the inferred model, using maximum likelihood estimates for the marginal node probabilities if `MLE=True`, otherwise using posterior mean estimates.

virtual_add_partition(b[, relabel])

Computes the entropy difference (negative log probability) if partition b were inserted the ensemble, after relabelling it if relabel=True.

virtual_remove_partition(b[, relabel])

Computes the entropy difference (negative log probability) if partition b were removed from the ensemble, after relabelling it if relabel=True.

add_partition(b, relabel=True)[source]#

Adds partition b to the ensemble, after relabelling it if relabel=True, and returns its index in the population.

align_mode(mode)[source]#

Relabel entire ensemble to align with another ensemble given by mode, which should be an instance of PartitionModeState.

copy(bs=None)[source]#

Copies the state. The parameters override the state properties, and have the same meaning as in the constructor.

get_B()[source]#

Return the total number of labels used.

get_M()[source]#

Return the number of partitions

get_coupled_state()[source]#

Return the instance of PartitionModeState representing the model at the upper hierarchical level.

get_marginal(g)[source]#

Return a VertexPropertyMap for Graph g, with vector<int> values containing the marginal group membership counts for each node.

get_max(g)[source]#

Return a VertexPropertyMap for Graph g, with int values containing the maximum marginal group membership for each node.

get_max_nested()[source]#

Return a hierarchical partition as a list of numpy.ndarray objects, containing the maximum marginal group membership for each node in every level.

get_nested_partition(i)[source]#

Returns nested partition with index i.

get_nested_partitions()[source]#

Returns all nested partitions.

get_partition(i)[source]#

Returns partition with index i.

get_partitions()[source]#

Returns all partitions.

posterior_cdev(MLE=True)[source]#

Return the uncertainty of the mode in the range \([0,1]\), using maximum likelihood estimates for the marginal node probabilities if `MLE=True`, otherwise using posterior mean estimates.

posterior_entropy(MLE=True)[source]#

Return the entropy of the random label model, using maximum likelihood estimates for the marginal node probabilities if `MLE=True`, otherwise using posterior mean estimates.

posterior_lprob(b, MLE=True)[source]#

Return the log-probability of partition b, using maximum likelihood estimates for the marginal node probabilities if `MLE=True`, otherwise using posterior mean estimates.

relabel()[source]#

Re-order group labels according to group sizes.

relabel_partition(b)[source]#

Returns a relabelled copy of partition b, according to its alignment with the ensemble.

remove_partition(i)[source]#

Removes partition with index i from the ensemble.

replace_partitions()[source]#

Removes and re-adds every partition, after relabelling, and returns the entropy difference (negative log probability).

sample_nested_partition(MLE=True, fix_empty=True)[source]#

Sampled a nested partition from the inferred model, using maximum likelihood estimates for the marginal node probabilities if `MLE=True`, otherwise using posterior mean estimates.

sample_partition(MLE=True)[source]#

Sampled a partition from the inferred model, using maximum likelihood estimates for the marginal node probabilities if `MLE=True`, otherwise using posterior mean estimates.

virtual_add_partition(b, relabel=True)[source]#

Computes the entropy difference (negative log probability) if partition b were inserted the ensemble, after relabelling it if relabel=True.

virtual_remove_partition(b, relabel=True)[source]#

Computes the entropy difference (negative log probability) if partition b were removed from the ensemble, after relabelling it if relabel=True.