CausalModel.idsFromNames
- CausalModel.idsFromNames(names)
The ids of nodes given by their names, in a container of the same type.
- Parameters:
names (
strorlistortupleorsetorfrozensetordict) – a node name, or a container of node names: a list, a tuple, a set, a frozenset or a dict (keys and values), possibly nested (e.g. a set of pairs of names)- Returns:
nameswhere every name is replaced by the id of its node- Return type:
intorlistortupleorsetorfrozensetordict- Raises:
TypeError – if an element is not a str, or a container is not a list, a tuple, a set, a frozenset nor a dict
pyagrum.NotFound – if a name is not the name of a node (a node without name can not be found by its id written as a string)
See also
namesFromIdsthe converse conversion
Example
import pyagrum as gum
cm = gum.CausalModel(gum.fastBN("Smoking->Cancer"), [("Genotype", ["Smoking", "Cancer"])])
cm.idsFromNames(["Genotype", "Cancer"])
# [2, 1]
Class