partition_overlap_center#
- graph_tool.inference.partition_overlap_center(bs, init=None, relabel_bs=False)[source]#
Find a partition with a maximal overlap to all items of the list of partitions given.
- Parameters:
- bslist of iterables of
int
values or list ofPropertyMap
List of partitions.
- inititerable of
int
values (optional, default:None
) If given, it will determine the initial partition.
- relabel_bs
bool
(optional, default:False
) If
True
the given list of partitions will be updated with relabelled values.
- bslist of iterables of
- Returns:
- c
numpy.ndarray
Partition containing the overlap consensus.
- r
float
Uncertainty in range
.
- c
Notes
This algorithm obtains a partition
that has a maximal sum of overlaps with all partitions given inbs
. It is obtained by performing the double maximization:where
is a bijective mapping between group labels, and is the contingency table between and . This algorithm simply iterates the above equations, until no further improvement is possible.The uncertainty is given by:
This algorithm runs in time
where is the number of partitions, is the length of the partitions and is the number of labels used.Parallel implementation.
If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.
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
Examples
>>> x = [5, 5, 2, 0, 1, 0, 1, 0, 0, 0, 0] >>> bs = [] >>> for m in range(100): ... y = np.array(x) ... y[np.random.randint(len(y))] = np.random.randint(5) ... bs.append(y) >>> bs[:3] [array([5, 5, 2, 0, 1, 0, 1, 0, 0, 0, 3]), array([5, 5, 2, 0, 4, 0, 1, 0, 0, 0, 0]), array([5, 5, 1, 0, 1, 0, 1, 0, 0, 0, 0])] >>> c, r = gt.partition_overlap_center(bs) >>> print(c, r) [1 1 2 0 3 0 3 0 0 0 0] 0.06818181... >>> gt.align_partition_labels(c, x) array([5, 5, 2, 0, 1, 0, 1, 0, 0, 0, 0])