CausalModel.namesFromIds
- CausalModel.namesFromIds(ids)
The names of nodes given by their ids, in a container of the same type.
- Parameters:
ids (
intorlistortupleorsetorfrozensetordict) – a node id, or a container of node ids: a list, a tuple, a set, a frozenset or a dict (keys and values), possibly nested (e.g. the arcs, a set of tuples)- Returns:
idswhere every id is replaced by the name of its node (a node without name gives its id as a string)- Return type:
strorlistortupleorsetorfrozensetordict- Raises:
TypeError – if an element is not an int, or a container is not a list, a tuple, a set, a frozenset nor a dict
pyagrum.NotFound – if an id is not the id of a node
See also
idsFromNamesthe converse conversion
Example
import pyagrum as gum
cm = gum.CausalModel(gum.fastBN("Smoking->Cancer"), [("Genotype", ["Smoking", "Cancer"])])
sorted(cm.namesFromIds(cm.children(cm.idFromName("Genotype")))) # a latent variable has a name
# ['Cancer', 'Smoking']
Class