BNLearner.idFromName

BNLearner.idFromName(var_name)
Parameters:

var_name (str) – a variable’s name

Returns:

the column id corresponding to a variable name

Return type:

int

Raises:

pyagrum.MissingVariableInDatabase – If a variable of the BN is not found in the database.

Example

import pyagrum as gum

with open("data.csv", "w") as f:  # C is mostly "A or B"
  f.write("A,B,C\n" + "0,0,0\n0,1,1\n1,0,1\n1,1,1\n" * 40 + "0,0,1\n0,1,0\n1,0,0\n1,1,0\n" * 5)
learner = gum.BNLearner("data.csv")
learner.idFromName("C")
# 2

Class

BNLearner