CausalModel.idsFromNames

CausalModel.idsFromNames(names)

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

Parameters:

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

names where every name is replaced by the id of its node

Return type:

int or list or tuple or set or frozenset or dict

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

namesFromIds

the converse conversion

Example

import pyagrum as gum

cm = gum.CausalModel(gum.fastBN("Smoking->Cancer"), [("Genotype", ["Smoking", "Cancer"])])
cm.idsFromNames(["Genotype", "Cancer"])
# [2, 1]

Class

CausalModel