other pyAgrum.lib modules¶

bn2roc¶

pyAgrum.lib.bn2roc.module_help(exit_value=1, message='')

defines help viewed if args are not OK on command line, and exit with exit_value

pyAgrum.lib.bn2roc.showROC(bn, csv_name, variable, label, visible=True, show_fig=False, with_labels=True)

Compute the ROC curve and save the result in the folder of the csv file.

Parameters: bn (pyAgrum.BayesNet) – a bayesian network csv_name (str) – a csv filename target (str) – the target label (str) – the target label visible (bool) – indicates if the resulting curve must be printed

bn2csv¶

Samples generation w.r.t to a probability distribution represented by a Bayesian network.

class pyAgrum.lib.bn2csv.CSVGenerator

Bases: object

Class for samples generation w.r.t to a probability distribution represented by a Bayesian network.

caching_probas(bn, node_id, n, par)
Parameters: bn (pyAgrum.BayesNet) – a Bayesian network node_id (int) – a node id n (int) – a node id par (list) – the node’s parents the node’s probabilities list
cachingnameAndParents(bn, n)

Compute a list of parents for node n in BN bn.

Parameters: bn (pyAgrum.BayesNet) – a Bayesian network n – (int) a node id n – (str) a node name a couple of name of n and list of parents names tuple
static draw(tab)

draw a value using tab as probability table.

Parameters: tab (list) – a probability table the couple (i,proba) tuple
static nameAndParents(bn, n)

Compute a list of parents for node n in BN bn.

Parameters: bn (pyAgrum.BayesNet) – a Bayesian network n – (int) a node id n – (str) a node name a couple of name of n and list of parents names tuple gum.IndexError – If the node is not in the Bayesian network
newSample(bn, seq)

Generate a sample w.r.t to the bn using the variable sequence seq (topological order)

Parameters: bn (pyAgrum.BayesNet) – a Bayesian network seq (list) – a variable sequence the coule (sample,log2-likelihood) tuple
proceed(name_in, name_out, n, visible, with_labels)

From the file name_in (BN file), generate n samples and save them in name_out

Parameters: name_in (str) – a file name name_out (str) – the output file n (int) – the number of samples visible (bool) – indicate if a progress bar should be displayed with_labels (bool) – indicate if values should be labelled or not the log2-likelihood of the n samples database double
pyAgrum.lib.bn2csv.generateCSV(name_in, name_out, n, visible=False, with_labels=True)

From the file name_in (BN file), generate n samples and save them in name_out

Parameters: name_in (str) – a file name name_out (str) – the output file n (int) – the number of samples visible (bool) – indicate if a progress bar should be displayed with_labels (bool) – indicate if values should be labelled or not the log2-likelihood of the n samples database double
pyAgrum.lib.bn2csv.module_help(exit_value=1)

defines help viewed if args are not OK on command line, and exit with exit_value

bn2scores¶

pyAgrum.lib.bn2scores.checkCompatibility(bn, fields, csv_name)

check if variables of the bn are in the fields

if not : return None if compatibilty : return a list of position for variables in fields

pyAgrum.lib.bn2scores.computeScores(bn_name, csv_name, visible=False, transforme_label=None)
pyAgrum.lib.bn2scores.getNumLabel(inst, i, label, transforme_label)
pyAgrum.lib.bn2scores.lines_count(filename)

count lines in a file

pyAgrum.lib.bn2scores.module_help(exit_value=1)

defines help viewed if args are not OK on command line, and exit with exit_value

pyAgrum.lib.bn2scores.stringify(s)

bn_vs_bn¶

pyAgrum.lib.bn_vs_bn.compareBN(name1, name2)
Parameters: name1 (str) – a BN filename name2 (str) – another BN filename “OK” if bn are the same, a description of the error otherwise str
pyAgrum.lib.bn_vs_bn.compareBNCPT(b1, b2)
Parameters: b1 (pyAgrum.BayesNet) – a Bayesian network b2 (pyAgrum.BayesNet) – another Bayesian network ‘OK’ if b2 have (at least) the same variable as b1 and their cpts are the same str
pyAgrum.lib.bn_vs_bn.compareBNParents(b1, b2)
Parameters: b1 (pyAgrum.BayesNet) – a Bayesian network b2 (pyAgrum.BayesNet) – another Bayesian network ‘OK’ if b2 have (at least) the same variable as b1 and their parents are the same. str
pyAgrum.lib.bn_vs_bn.compareBNVariables(b1, b2)
Parameters: bn1 (pyAgrum.BayesNet) – a Bayesian network bn2 (pyAgrum.BayesNet) – another Bayesian network ‘OK’ if BN are composed of the same variables, indicates a non-existing variable otherwise str
pyAgrum.lib.bn_vs_bn.compareCPT(b1, cpt1, b2, cpt2)
Parameters: b1 (pyAgrum.BayesNet) – a Bayesian network cpt1 (pyAgrum.Potential) – one of b1’s cpts b2 (pyAgrum.BayesNet) – another Bayesian network cpt2 (pyAgrum.Potential) – one of b2’s cpts ‘OK’ if CPTs are the same str gum.KeyError – If cpts are not from the same variable
pyAgrum.lib.bn_vs_bn.graphicalBNDiff(bn1, bn2)

Return a pydotplus graph that compares the arcs of bn1 (reference) with those of bn2. full black line: the arc is common for both full red line: the arc is common but inverted in bn2 dotted black line: the arc is added in bn2 dotted red line: the arc is removed in bn2

Parameters: bn1 (BayesNet) – referent model for the comparison bn2 (BayesNet) – bn compared to the referent model the result dot graph
pyAgrum.lib.bn_vs_bn.module_help(exit_value=1)

defines help viewed if args are not OK on command line, and exit with exit_value

pyAgrum.lib.bn_vs_bn.nodeId(bn, n)
Parameters: bn (pyAgrum.BayesNet) – a Bayesian network n (str) – the name of the node the id of the node int gum.IndexError – If the node is not in the Bayesian network
pyAgrum.lib.bn_vs_bn.parents_name(bn, n)
Parameters: bn (pyAgrum.BayesNet) – a Bayesian network n – (str) the name of the node n – (int) the id of the node a list of name of parents of node n map gum.IndexError – If the node is not in the Bayesian network

pretty_print¶

pyAgrum.lib.pretty_print.bn2txt(aBN)

Representation of all CPTs of a gum.BayesNet

Parameters: aBN – the bayes net or the name of the file
pyAgrum.lib.pretty_print.cpt2txt(cpt, digits=4)

string representation of a gum.Potential

Parameters: cpt – the Potential to represent the string representation
pyAgrum.lib.pretty_print.max_length(v)
pyAgrum.lib.pretty_print.module_help(exit_value=1)

defines help viewed if args are not OK on command line, and exit with exit_value