API reference

andrey.metrics.number_of_latents#

andrey.metrics.number_of_latents(graph)[source]#

Count of nodes flagged LATENT (0 when node_types is unset).

Return type:

int

Examples

>>> import numpy as np
>>> from andrey.core import GraphStructure, LATENT, OBSERVED
>>> m = np.array([[0, 0, 2], [0, 0, 2], [1, 1, 0]], dtype=np.int8)
>>> types = np.array([OBSERVED, OBSERVED, LATENT], dtype=np.int8)
>>> number_of_latents(GraphStructure.from_numpy(m, kind="dag", node_types=types))
1