CausalModel.namesFromIds

CausalModel.namesFromIds(ids)

The names of nodes given by their ids, in a container of the same type.

Parameters:

ids (int or list or tuple or set or frozenset or dict) – 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:

ids where every id is replaced by the name of its node (a node without name gives its id as a string)

Return type:

str or list or tuple or set or frozenset or dict

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

idsFromNames

the 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

CausalModel