API Reference

The HUGIN Python API consists of the pyhugin module.

Short descriptions can be found for all classes and their members in the pydoc comments. However, additional information might be relevant for different tasks. In such cases, the HUGIN API Reference Manual (the api-manual.pdf file) will be a good place to look. It contains detailed documentation of the HUGIN C API, which is the basis of the HUGIN Python API.

exception HuginException(*args)

The HuginException can be raised by any function in the Hugin Python API.

class NetworkModel(*_hhh156)

The NetworkModel class is an abstract class with two subclasses: Domain and Class.

close_log_file()

Closes the log file associated with this NetworkModel.

delete()

Deletes this NetworkModel.

generate_tables()

Generate tables for all relevant nodes of this NetworkModel.

get_attribute(key)

Returns an attribute value. That is, the value associated with a key in the attribute list for this NetworkModel.

Returns None if no value is associated with the given key.

get_attributes()

Returns the list of attributes associated with this NetworkModel as a list of key-value tuples.

get_file_name()

Returns the file name most recently used for loading or saving this NetworkModel.

get_log_file()

Returns the name of the most recent log file opened by open_log_file.

get_node_by_name(name)

Returns a Node by name.

If no node by the given name exists, None is returned.

get_node_size()

Retrieve the dimensions of nodes of this NetworkModel as a tuple (width, height).

get_nodes()

Returns the Nodes of this NetworkModel in a list.

is_alive()

Is this NetworkModel object alive?

open_log_file(file_name, append=False)

Opens a log file to be associated with this NetworkModel.

Log file can be opened in either append or create mode.

parse_nodes(file_name)

This function parses the list of node names stored in the file with name ‘file_name’.

The node names must identify nodes of this NetworkModel; it is an error, if some node cannot be found.

save_as_net(file_name)

Save the network model as a text file with name file_name. The format of the file is as required by the NET language.

Note that if a NET file is parsed and then saved again, any comments in the original file will be lost. Also note that if (some of) the nodes have not been assigned names, then names will automatically be assigned.

set_attribute(key, value)

Inserts the key/value pair in the attribute list for this NetworkModel. If the key is already defined, the value is updated. If no value is provided, the attribute is removed.

set_node_size(width, height)

Set the width and height dimensions of nodes of this NetworkModel to width and height, respectively.

to_net_string()

Create a NET description of this NetworkModel.

class Clique(*_hhh156)

Represents the cliques in the JunctionTree.

get_junction_tree()

Return the junction tree to which this clique belongs.

get_members()

Retrieve the list of nodes comprising the members of this clique.

get_neighbors()

Retrieve the list of cliques containing the neighbors of this clique in the junction tree to which this clique belongs.

is_alive()

Is this Clique object alive?

class JunctionTree(*_hhh156)

Thic class represents the JunctionTrees in a compiled domain.

cg_evidence_is_propagated()

Test if CG evidence has been propagated for this JunctionTree.

equilibrium_is(equilibrium)

Test if the equilibrium of this JunctionTree is specific equilibrium.

evidence_is_propagated()

Test if evidence has been propagated for this JunctionTree.

evidence_mode_is(mode)

Test if the equilibrium of this JunctrionTree could have been obtained through a propagation using specific evidence incorporation mode.

evidence_to_propagate()

Test if there is any node in this JunctionTree with new evidence as compared to the evidence propagated.

get_cliques()

Retrieve the list of Cliques that form the set of vertices of this JunctionTree.

get_conflict()

Return the conflict of evidence for this JunctionTree computed during the most recent propagation. If no evidence has been propagated, 1 is returned.

get_root()

Returns the root clique of this JunctionTree.

get_total_cg_size()

Return the total CG size of all clique and separator tables associated with this JunctionTree.

get_total_size()

Return the total size (i.e., the total number of discrete configurations) of all clique and separator tables associated with this JunctionTree.

is_alive()

Is this JunctionTree object alive?

likelihood_is_propagated()

Test if likelihood evidence has been propagated for this JunctionTree.

propagate(equilibrium=EQUILIBRIUM.SUM, evidence_mode=EVIDENCE_MODE.NORMAL)

Propagates evidence in this JunctionTree.

tables_to_propagate()

Does this JunctionTree contain updated tables that have not been propagated?

class ClassCollection(*_hhh156)

Classes are grouped into ClassCollections.

Each class must belong to exactly one ClassCollection. A ClassCollection can be considered a closed world of interdependent Classes (i.e., Bayesian networks and LIMIDs). That is, each Class may contain instances of other Classes of the ClassCollection, but not of Classes of other ClassCollections.

Several operations are supported for ClassCollections: * Creation and deletion * Addition of Class objects specified in NET files * Saving to a NET file * Retrieval of the list of Class objects * Retrieval of a Class object by its name

delete()

Deletes this ClassCollection and all its Classses.

get_class_by_name(name)

Returns the Class of this ClassCollection that has the given name.

If no such class exists, None is returned.

get_members()

Retrieve the list of classes belonging to this ClassCollection.

is_alive()

Is this ClassCollection object alive?

static load_class_collection(file_name, password=None)

Constructs a class collection by loading the corresponding Hugin Knowledge Base (HKB) file.

The HKB file must contain a class collection.

parse_classes(net_string_or_file_name, get_class_handler=None, error_handler=None)

Parse a NET specification of classes: net_string_or_file_name must be either the name of a NET file, or it must contain the NET specification.

If an instance of a class not present in the ClassCollection is declared in the NET specification, get_class_handler is called with the name of the class and the ClassCollection instance. The get_class_handler function is supposed to load the named class into ClassCollection (if it does not, then parsing is terminated). If the named class contains instances of other classes not present in the ClassCollection, these classes must be loaded (or constructed) as well.

If an error is detected (or a warning is issued), the error_handler function is called with a line number (indicating the location of the error within the NET specification) and a string that describes the error.

save_as_kb(file_name, password=None)

Saves this ClassCollection as a password-protected Hugin Knowledge Base (HKB) file. If password is non-null, the file will be password protected. This password must be used in order to load the file.

save_as_net(file_name)

Save this ClassCollection as a text file with name file name. The format of the file is as required by the NET language.

Note that if a NET file is parsed and then saved again, any comments in the original file will be lost. Also note that if (some of) the nodes have not been assigned names, then names will automatically be assigned.

to_net_string()

Create a NET description of this ClassCollection.

class Class(class_collection, name=None)

Instances of the Class class represent object-oriented Bayesian networks and LIMIDs.

Such an instance can contain nodes representing instances of other network classes and so on. To use an instance (i.e., propagate evidence and calculate updated beliefs and expected utilities), it must first be unfolded to a plain Bayesian network or LIMID. The Domain() constructor handles this.

delete()

Deletes this Class, including all Nodes belonging to it.

get_class_collection()

Retrieve the ClassCollection to which this Class belongs.

get_inputs()

Retrieve the list of input Nodes associated with this Class.

get_instances()

Retrieve a list of all instances of this Class.

The list contains an instance Node for each instance of this Class.

get_name()

Returns the name of this Class.

If this class has not previously been assigned a name, a valid name will automatically be assigned.

get_outputs()

Retrieve the list of output Nodes associated with this Class.

new_instance(of_cls)

Creates a new instance Node (in this Class) representing the Class ‘of_cls’.

set_name(name)

Sets the name of this Class.

The name must be valid, i.e., it must follow the rules that govern the validity of C identifiers, and no other class in the ClassCollection to which this Class belongs must have the same name.

class Domain(cls=None, number_of_slices=None)
adapt()

This function updates (adapts), for all discrete chance nodes of domain, the experience count (retrieval of experience) and the conditional probability distribution (dissemination of experience) for all parent configurations having a valid experience count and a valid fading factor.

This adaptation is based on the propagated evidence (hence domain must be compiled). The evidence must have been propagated with equilibrium equal to EQUILIBRIUM.SUM and evidence-incorporation-mode equal to EVIDENCE_MODE.NORMAL.

adapt_class_tables_using_fractional_update()

For each discrete node of this Domain (which must be a runtime domain) such that both the node and its source node have experience tables, the conditional probability and experience tables of both nodes are learned/updated, and the tables of the domain node will be identical to those of its source node.

Nodes (in this domain or in the object-oriented model) without experience tables will not be modified.

This function updates (adapts), for all discrete nodes.

adapt_class_tables_using_online_em(alpha)

This function updates (adapts), for all discrete chance nodes of this Domain, the experience count (retrieval of experience) and the conditional probability distribution (dissemination of experience) for all parent configurations having a valid experience count. (Fading factors are ignored.)

The alpha argument and the total experience determine the learning rate of the update step.

add_cases(dataset, first_row, number_of_rows)

Adds the specified range of rows of the data set to this Domain as cases.

approximate(epsilon)

Removes ‘near-zero’ probabilities from the clique probability tables.

For each Clique in this domain, a value delta is computed such that the sum of all elements less than delta in the (discrete part) of the clique table is less than epsilon. These elements (less than delta) are then set to 0.

cg_evidence_is_propagated()

Test if CG evidence has been propagated for this domain.

compile()

Compile domain, using the default triangulation method. It is considered an error, if domain is already compiled.

compress()

Remove the zero entries from the clique and separator tables of the junction trees of this domain.

The compression function returns a measure of the compression achieved. This measure should be less than 1, indicating that the compressed domain requires less memory than the uncompressed version. If the measure is larger than 1, the compressed domain will actually use more memory than the uncompressed version.

DBN: this domain must not be a DBN runtime domain that has been triangulated using triangulate_dbn().

compute_dbn_predictions(instants)

This operation computes ‘predictions’ for all nodes at time instants following the time window.

compute_sensitivity_data(nodes, states)

Computes the constants of the sensitivity functions for the specified output probabilities and all CPT parameters in the network. The output probabilities are specified using a list of (discrete chance) nodes and a list of corresponding states.

delete()

Deletes this Domain, including all Node and JunctionTree objects belonging to it.

enter_case(index)

Enter the case data from case index as evidence into this domain.

equilibrium_is(equilibrium)

Test if the equilibrium of all junction trees of this domain is specific equilibrium.

evidence_is_propagated()

Test if evidence has been propagated for this domain.

evidence_mode_is(mode)

Test if the equilibrium of all junction trees of this domain could have been obtained through a propagation using specific evidence incorporation mode.

evidence_to_propagate()

Test if there is any node with changed evidence compared to the most recent propagation (if any).

find_map_configurations(nodes, pmin)

Find all configurations of nodes with probability at least pmin.

fine_tune_nb_tables(target)

This function fine-tunes a Naive Bayes (NB) model using training data.

The method makes small adjustments to the conditional probabilities of the attribute nodes in order to obtain more correct classifications. If these adjustments do not result in a better model, the original model is preserved.

The domain must represent a Naive Bayes model with initial conditional probability tables (for example, estimated using the EM algorithm). The network must contain only discrete chance nodes. Case data must be specified in advance.

get_AIC()

Get the AIC score of the case data with respect to the graphical model of this domain.

get_BIC()

Get the BIC score of the case data with respect to the graphical model of this domain.

get_approximation_constant()

Return the approximation constant of the most recent (explicit or implicit) approximation operation.

get_case_count(index)

Retrieve the case-count associated case index in this domain.

get_concurrency_level()

This function returns the current concurrency level associated with this domain.

get_conflict()

Return the conflict of evidence for this domain computed during the most recent propagation. If no evidence has been propagated, 1 is returned.

get_d_connected_nodes(source, hard, soft=[])

Performs a d-separation test and returns a list of d-connected nodes. Assuming evidence on the specified evidence nodes, this method returns the list of nodes that are d-connected to the specified list of source nodes.

get_d_separated_nodes(source, hard, soft=[])

Performs a d-separation test and returns a list of d-separated nodes. Assuming evidence on the specified evidence nodes, this method returns the list of nodes that are d-separated to the specified list of source nodes.

get_elimination_order()

Return a list of nodes in the order used to triangulate this domain.

get_em_concurrency_level()

Returns the number of threads to be created by the EM algorithm.

get_expected_utility()

Returns the total expected utility associated with this Domain.

get_explanation(index)

This function returns the explanation (i.e., a subset of the evidence nodes) identified by index.

get_explanation_score(index)

Return the impact score of the explanation that is returned by get_explanation() with index as argument.

get_grain_size()

This function returns the current value of the grain size parameter associated with the domain.

get_junction_trees()

Returns the JunctionTrees of this Domain..

get_log_likelihood()

Get the log-likelihood of the case data with respect to the graphical model of domain. This is computed using the current conditional probability tables.

If this function is called immediately after the EM algorithm has been run (for example, using learn_tables()), the log-likelihood will be computed with respect to the final tables computed by the EM algorithm.

But the function can also be used without the EM algorithm.

get_log_likelihood_tolerance()

Retrieve the current setting of the log-likelihood tolerance for this domain.

get_log_normalization_constant()

Retrieves the log of the normalization constant for the most recent propagation.

get_map_configuration(index)

This function returns the configuration (an n-tuple) identified by index among the configurations with probability at least pmin as specified in the most recent successful call to find_map_configurations().

get_marginal(nodes)

Compute the marginal table for the specified list of nodes with respect to the (imaginary) joint potential, determined by the current potentials on the junction tree(s) of this domain. The nodes must be distinct discrete or continuous nodes, and they must belong to this domain. If the nodes list contains continuous nodes, they must be last in the list. This operation is not allowed on compressed domains.

Important: The table returned is owned by the application, and it is the responsibility of the application to deallocate it by calling the delete function.

get_max_number_of_em_iterations()

Retrieve the current setting for this domain of the maximum number of iterations for the EM algorithm used by learn_tables().

get_max_number_of_separators()

Retrieve the current setting for this domain of the maximum size of separators to keep for the total weight triangulation method.

get_nb_fine_tune_iterations_limit()

Retrieve the current setting for this domain of the limit for the number of consecutive failed iterations of the Naive Bayes (NB) fine-tuning algorithm.

get_nb_fine_tune_learning_rate()

Retrieve the learning rate of the Naive Bayes (NB) fine-tuning algorithm.

get_normal_deviate(mean, variance)

Use the pseudorandom number generator for this domain to sample a real number from the normal (also known as the Gaussian) distribution with mean mean and variance variance.

get_normalization_constant()

Retrieves the normalization constant for the most recent propagation.

For sum-propagation, the normalization constant is equal to the probability of the evidence propagated. For max-propagation, the normalization constant is the probability of the most probable configuration with the evidence incorporated.

get_number_of_cases()

Returns the number of cases currently allocated for domain.

get_number_of_explanations()

Return the total number of time steps that the time window of domain has been moved.

get_number_of_map_configurations()

This function returns the number of configurations found by the most recent successful call to find_map_configurations(). If no such call has been made (or the results of the call are no longer available), a negative number is returned.

get_probability_of_map_configuration(index)

Return the probability of the configuration returned by get_map_configuration(index).

get_sensitivity_set()

Return the sensitivity set computed by the most recent call to Node.compute_sensitivity_data().

get_sensitivity_set_by_output(output)

Return the sensitivity set corresponding to the specified output probability: output refers to one of the output probabilities specified in the most recent call to Domain.compute_sensitivity_data().

get_significance_level()

Retrieve the current significance level for domain.

get_uniform_deviate()

Use the pseudorandom number generator for this domain to sample a real number from the uniform distribution over the interval [0,1).

initialize()

Retract all evidence specified for the nodes of this domain and establish the initial state of the inference engine.

initialize_dbn_window()

Retract evidence for all nodes of domain, move the time window back to its initial position, and establish the initial state of the inference engine.

is_compiled()

Tests whether this Domain is compiled.

A domain is ‘compiled’ if it is triangulated and junction tree tables are created.

is_compressed()

Test whether this domain is compressed.

is_triangulated()

Test whether domain is triangulated.

is_triangulated_for_bk()

Test whether this domain has been triangulated using triangulate_dbn_for_bk().

learn_class_tables()

For each node of this domain (which must be a runtime domain) such that both the node and its source node have experience tables, the conditional probability and experience tables of both nodes are learned/updated, and the tables of the domain node will be identical to those of its source node.

Nodes (in domain or in the object-oriented model) without experience tables will not be modified.

DBN: If domain is a DBN runtime domain, then the time window offset must be zero.

learn_hnb_structure(target)

This function learns a Hierarchical Naive Bayes (HNB) model from data. The domain must contain only chance nodes and no edges. Case data must be specified in advance.

learn_structure()

This function creates directed links (found by the PC algorithm) between the nodes of this domain which must contain only chance nodes and no edges. Case data must be specified in advance.

learn_tables()

Learn the conditional probability tables for all nodes of domain having experience tables.

learn_tree_structure(root=None, target=None)

This function learns a tree-structured network model from data. If ‘root’ is specified, then a Chow-Liu tree model with ‘root’ as root is learned. Then, if ‘target’ is also specified, this tree is turned into a TAN model by adding ‘target’ as parent of all other nodes of this Domain. If ‘root’ and ‘target’ are both ‘None’, then a Rebane-Pearl polytree model is learned. The domain must contain only chance nodes and no edges. Case data must be specified in advance.

likelihood_is_propagated()

Test if likelihood evidence has been propagated for this domain.

static load_domain(file_name, password=None)

Load a domain from the HUGIN KB file named file_name.

Returns a Domain instance.

move_dbn_window(delta)

This operation (which assumes that domain is a compiled DBN runtime domain) moves the time window forward by delta steps

new_case()

Allocate storage within this domain to hold a new case.

parse_case(file_name, error_handler=None)

Parses the case stored in file file_name and enters the associated findings into this Domain.

All existing evidence in the Domain is retracted before entering the case findings.

parse_cases(file_name, error_handler=None)

Parses the cases stored in file file_name and enters the cases into this Domain.

static parse_domain(net_string_or_file_name, error_handler=None)

Parse a NET specification of a domain: net_string_or_file_name must either be the name of a NET file, or it must contain the NET specification.

If an error is detected (or a warning is issued), the error_handler function is called with a line number (indicating the location of the error within the NET specification) and a string that describes the error.

propagate(equilibrium=EQUILIBRIUM.SUM, evidence_mode=EVIDENCE_MODE.NORMAL)

Establishes the specified equilibrium using the evidence mode indicated for incorporation of evidence on all JunctionTrees of this Domain.

Also, revised beliefs will be computed for all nodes.

reset_inference_engine()

Establish the initial state of the inference engine of this domain - sum-equilibrium with no evidence incorporated.

retract_findings()

Retract findings for all nodes of this domain. This is useful when a new set of observations should be entered.

DBN: Evidence that has been moved out of the time window by move_dbn_window() will not be retracted.

save_as_kb(file_name, password=None)

Save domain as a HUGIN KB to a file. If password is not None, then the HKB file will be protected by the given password (i.e., the file can only be loaded if this password is supplied again when loading).

Note: domain must not be a (compiled) DBN runtime domain that has been triangulated using triangulate_dbn().

save_case(file_name)

Saves all evidence entered in this Domain in file file_name (if the file exists, it is overwritten).

save_cases(file_name, nodes, cases=None, case_counts=False, separator=', ', missing='')

Saves all cases entered in this Domain in a file with the given file_name (if the file exists, it is overwritten).

save_to_memory()

Creates a copy in memory of the belief and JunctionTree tables of this Domain.

This operation can only be performed if the domain is compiled, the current equilibrium equals EQUILIBRIUM.SUM, and no evidence has been incorporated.

seed_random(seed)

Seed the pseudorandom number generator used by simulate() with seed.

select_features(target)

Returns the nodes of the domain, in order of decreasing relevance, for the classification problem with ‘target’ as target.

set_case_count(index, count)

Set the case-count for the case with index in this domain to count.

set_concurrency_level(level)

This function sets the level of concurrency associated with the domain (this must be a positive number). Setting the concurrency level parameter to 1 will cause all table operations (involving tables originating from domain) to be performed sequentially. The initial value of this parameter is 1.

set_em_concurrency_level(level)

Sets the number of threads to be created by the EM algorithm. The EM algorithm exploits concurrency by partitioning the set of cases into subsets of approximately equal size. Each subset is then processed by a thread that has a copy of the (compiled) domain, enabling the threads to perform inference in parallel.

Setting this parameter to 1 causes the EM algorithm to execute single-threaded. The initial value of this parameter is 1.

set_grain_size(size)

This function sets the grain size parameter associated with domain (this value must be positive). The initial value of this parameter is 10000.

set_initial_triangulation(order)

Specify an intial triangulation to be used by the total weight triangulation method.

The triangulation is specified in the form of the elimination sequence order (a list of nodes containing each discrete and each continuous node of the domain exactly once, and continuous nodes must precede discrete nodes).

set_log_likelihood_tolerance(tolerance)

Specify that the EM algorithm used by learn_tables() should terminate when the relative difference between the log-likelihood for two successive iterations becomes less than tolerance (which must be a positive number).

set_max_number_of_em_iterations(count)

Specify that the EM algorithm used by learn_tables() should terminate when count number of iterations have been performed (if count is positive).

If count is zero, no limit on the number of iterations is imposed (this is also the initial setting).

set_max_number_of_separators(count)

Specify the maximum number of minimal separators to generate when using the total weight method for triangulating the domain.

If count is zero, then the bound is set to unlimited which is also the default value.

set_max_separator_size(size)

Specify the maximum size of minimal separators to keep when using the total weight method for triangulating this domain.

If size is zero, then the bound is set to unlimited which is also the default value.

set_nb_fine_tune_iterations_limit(limit)

Specify the limit for the number of consecutive failed iterations of the Naive Bayes (NB) fine-tuning algorithm. When ‘limit’ iterations over the training data, showing no improvements of the classification accuracy, have been performed, the algorithm terminates.

set_nb_fine_tune_learning_rate(learning_rate)

Set the learning rate of the Naive Bayes (NB) fine-tuning algorithm. The default value is 0.01.

set_number_of_cases(count)

This function adjusts the storage capacity for cases of this domain.

set_significance_level(probability)

Set the significance level (i.e., the probability of rejecting a true independence hypothesis) to probability (a value between 0 and 1) for this domain. The default value is 0.05.

simulate()

If domain is compiled, sample a configuration with respect to the current distribution on the junction tree(s).

tables_to_propagate()

Are there any nodes in this domain having a (conditional probability, policy, or utility) table that has changed since the most recent compilation or propagation operation?

triangulate(triangulation_method=TRIANGULATION_METHOD.BEST_GREEDY)

Perform triangulation of this domain using the specified triangulation method. It is considered an error, if the domain is already triangulated.

triangulate_dbn(triangulation_method=TRIANGULATION_METHOD.BEST_GREEDY)

This function is similar to triangulate() except that the interface between successive time slices are made complete.

triangulate_dbn_for_bk(triangulation_method=TRIANGULATION_METHOD.BEST_GREEDY)

This function creates separate compiled structures for the time slices of the DBN runtime domain. This is used to maintain (approximate) factored representations of the distributions of the interfaces between the time slices.

triangulate_with_order(order)

Triangulate domain using list of nodes as elimination sequence. The list must contain each discrete and each continuous node of the domain exactly once, and continuous nodes must precede discrete nodessee.

It is considered an error, if domain is already triangulated.

uncompile()

Remove the data structures of domain produced by the compile or triangulate functions. If domain is not compiled or triangulated, nothing is done.

update_policies()

This function updates (using the SPU algorithm) the policies of uninstantiated decisions in domain such that the overall expected utility of the decision problem is maximized.

Note that this maximum is not guaranteed to be a global maximum - it is possible that it is a local maximum. Evidence is taken into account (so the updated policies are effectively conditioned on the evidence).

class Node(network_model, category=CATEGORY.CHANCE, kind=KIND.DISCRETE, subtype=SUBTYPE.LABEL)

Nodes are one of the fundamental objects used in the construction of Bayesian networks and LIMIDs.

All nodes need a NetworkModel (i.e., a Class or a Domain); that is, the network must exist before its nodes can be created.

add_parent(parent)

Add a directed link from the new parent to this Node.

add_to_inputs()

Add this Node to the set of input Nodes associated with the Class to which this Node belongs.

add_to_outputs()

Add this Node to the set of output Nodes associated with the Class to which this Node belongs.

case_is_set(index)

Test whether the value of this Node in specified case is currently set.

compute_explanation_data(x, Y, y, max_subset_size)

Computes Bayes factor data for all (nonempty) subsets of evidence nodes up to the specified maximum size.

Two hypotheses are compared: (this node)=x and Y=y.

For each subset of evidence nodes (up to the specified maximum size), the Bayes factor (the support for the first hypothesis relative to the second hypothesis) is computed. The results of the computations can be accessed using Domain.get_explanation() and Domain.get_explanation_score().

compute_sensitivity_data(state)

Computes the constants of the sensitivity functions for the specified output probability and all CPT/policy parameters in the network.

create_temporal_clone()

This function creates a temporal clone of this Node.

delete()

Deletes this Node.

enter_finding(state, value)

Specify ‘value’ as the finding value for ‘state’ of this discrete Node.

The finding value must be nonnegative, and state must specify a valid state of node.

enter_value(value)

Specify that this continuous Node has the value ‘value’.

evidence_is_entered()

Is the evidence potential, currently registered at this Node (which must be a discrete or a continuous node), non-vacuous?

evidence_is_propagated()

Is the evidence potential for this Node (which must be a discrete or a continuous node), incorporated within the current junction tree potentials, non-vacuous?

evidence_to_propagate()

Is the entered and propagated evidence for thos Node (which must be a discrete or a continuous node) different?

generate_table()

Generate the table of node from its model (a missing model is a usage error).

get_alpha(i)

Returns the alpha component of the CG distribution of this continuous chance Node given the discrete parent configuration corresponding to i.

get_attribute(key)

Returns an attribute value. That is, the value associated with a key in the attribute list for this Node.

Returns None if no value is associated with the given key.

get_attributes()

Returns the list of attributes associated with this Node as a list of key-value tuples.

get_belief(state)

Gets the belief for the specified state of this Node.

Note that if findings have been entered since the most recent propagation, the beliefs returned may not be up-to-date.

get_beta(parent, i)

Returns the beta component of the CG distribution of this continuous chance Node given a continuous parent and the discrete parent configuration corresponding to i.

get_case_state(index)

Retrieve the state value of this discrete Node associated with specified case index.

get_case_value(index)

Retrieve the value of this continuous Node associated with specified case index.

get_category()

Returns the category of this Node.

get_children()

Retrieves a list with the children of this Node.

get_distribution()

This function computes the distribution for this CG Node. No value must be propagated for the Node.

Important: The table returned is owned by the application, and it is the responsibility of the application to deallocate it by calling the delete function.

get_edge_constraint(node)
get_entered_finding(state)

Retrieve the finding value currently registered at this discrete Node for state ‘state’.

get_entered_value()

Retrieve the entered value for this continuous Node.

get_entropy()

Compute the entropy of node (which must be a discrete node).

get_expected_utility(state=0)

Get the expected utility.

If node is a discrete node, the expected utility associated with state is returned. If node is a utility node, the contribution of node to the overall expected utility is returned (in this case, specify 0 as the value for state).

get_experience_table()

This function returns the experience Table of this Node (which must be a chance node).

If this Node does not have an experience Table, then one will be created.

get_fading_table()

This function returns the fading Table of this Node (which must be a discrete chance node).

If this Node does not have an fading Table, then one will be created.

get_gamma(i)

Returns the gamma component of the CG distribution of this continuous chance Node given the discrete parent configuration corresponding to i.

get_home_class()

Retrieve the Class to which this Node belongs.

get_home_domain()

Retrieve the Domain to which this Node belongs.

get_input(input)

For the class instance represented by this instance Node instance, retrieve the actual input node bound to the formal input Node ‘input’.

get_instance()

Retrieve the instance Node with which this Node is associated.

get_instance_class()

Retrieve the Class of which this instance Node instance is an instance.

get_junction_tree()

Returns the JunctionTree to which this Node belongs.

get_kind()

Returns the kind of this Node.

get_label()

Returns the label assigned to this Node.

If this node has not been assigned a label, None is returned.

get_master()

Retrieve the output Node from which this Node was cloned.

get_max_utility()

Get the maximum possible utility.

Returns the maximum possible utility associated with this utility node. This is the largest utility value for this node with a positive probability as computed by the most recent inference operation.

get_mean()

Returns the mean of the marginal distribution of this continuous chance node.

get_min_utility()

Get the minimum possible utility.

Returns the minimum possible utility associated with this utility node. This is the smallest utility value for this node with a positive probability as computed by the most recent inference operation.

get_model()

Return the model associated with this Node.

get_mutual_information(other)

Compute the mutual information of this Node and other (which must be discrete nodes)

get_name()

Returns the name of this Node.

If this node has not previously been assigned a name, a valid name will automatically be assigned.

get_number_of_states()

Returns the number of states of this node.

The states are numbered from 0 to N-1, where N is the number of states of the node.

get_output(output)

Retrieve the output clone that was created from ‘output’ when this instance Node was created.

get_parents()

Retrieves a list with the parents of this Node.

get_position()

Retrieve the position of this Node as a tuple (x, y).

get_predicted_belief(state, time)

Retrieve the belief of this Node for ‘state’ at time instant ‘time’ as computed by the most recent successful call to Domain.compute_dbn_predictions(), provided that the predictions are still available.

get_predicted_mean(time)

Retrieve the mean value of this Node at time instant ‘time’ as computed by the most recent successful call Domain.compute_dbn_predictions(), provided that the predictions are still available.

get_predicted_value(time)

Retrieve the value of this Node at time instant ‘time’ as computed by the most recent successful call to Domain.compute_dbn_predictions(), provided that the predictions are still available.

get_predicted_variance(time)

Retrieve the variance of this Node at time instant ‘time’ as computed by the most recent successful call to Domain.compute_dbn_predictions(), provided that the predictions are still available.

get_propagated_finding(state)

Retrieve the finding value incorporated within the current junction tree potentials for state ‘state’ of this discrete Node.

get_propagated_value()

Retrieve the value that has been propagated for this continuous Node.

get_quantile(probability)

Gets the quantile corresponding to the specified ‘probability’ argument of the inverse cumulative distribution function of this discrete numeric node.

get_requisite_ancestors()

Return a list of the requisite ancestors of this Node.

get_requisite_parents()

Return a list of the requisite parents of this Node.

get_sampled_state()

Retrieve the state index of this Node (which must be a discrete node) within the configuration generated by the most recent call to Domain.simulate().

get_sampled_utility()

Return the utility value in the potential table of this Node (which must be a utility node) identified by the configuration generated by the most recent call to Domain.simulate().

get_sampled_value()

If this Node is a continuous node, then the value of node within the configuration generated by the most recent call to Domain.simulate() is returned.

If this Node is a real-valued function node, the function associated with Node is evaluated using the configuration generated by Domain.simulate() as input and the result is returned.

get_sensitivity_constants(input)

Returns the four constants of the specified sensitivity function as a four-tuple. The output probability of this function was specified in the preceding call to Node.compute_sensitivity_data().

get_sensitivity_constants_by_output(input, output)

Returns the four constants of the specified sensitivity function as a four-tuple. The output probability of this function must be one of the output probabilities specified in the preceding call to Domain.compute_sensitivity_data().

get_source()

Return the source list of this Node.

get_state_index_from_label(label)

Returns the index of the state matching the specified label.

If there is no (unique) state with the specified state label, -1 is returned.

get_state_index_from_value(value)

Get the index of the state matching the specified value.

If there is no (unique) state with the specified state value, -1 is returned.

get_state_label(index)

Returns the label of the specified state.

get_state_value(state)

Gets the value associated with a particular state of this numbered node or the low value of the interval associated with a particular state of this interval node.

For interval nodes, to indicate the right endpoint of the rightmost interval, specify state equal to the number of states of this interval node.

get_subtype()

Returns the subtype of this Node.

get_table()

Retrieve the table associated with this Node (which must be a discrete, a continuous, or a utility node).

get_temporal_clone()

Retrieve the temporal clone of this Node.

get_temporal_master()

Retrieve the temporal master of this Node.

get_value()

Gets the value of this FunctionNode.

The value is computed using the function associated with the node. If the function refers to other nodes, then the values of those nodes are derived from the results of the most recent inference operation.

get_variance()

Returns the variance of the marginal distribution of this continuous chance node.

get_variance_of_utility()

Get the variance of the utility.

Returns the variance of the utility associated with this utility node. This is the variance of the utility value computed by the most recent inference operation.

has_experience_table()

This function tests whether this Node has an experience table.

has_fading_table()

This function tests whether this Node has a fading table.

is_alive()

Is this Node object alive?

likelihood_is_entered()

Is the evidence potential, currently registered at this Node (which must be a discrete or a continuous node), a likelihood?

likelihood_is_propagated()

Is the evidence potential for this Node (which must be a discrete or a continuous node), incorporated within the current junction tree potentials, a likelihood?

remove_from_inputs()

Removes this Node from the set of input Nodes associated with the Class to which this Node belongs.

remove_from_outputs()

Removes this Node from the set of output Nodes associated with the Class to which this Node belongs.

remove_parent(parent)

Delete the directed link from parent to this Node.

reorder_states(order)

Reorder the states of this Node according to the specified order (a list of string state labels constituting the new desired order).

retract_findings()

Retracts all findings for this Node.

For discrete nodes this is equivalent to setting the finding value to 1 for all states of this node.

reverse_edge(node)

Reverses the edge between this Node and the specified neighbor. Both nodes must be chance nodes, and they must be of the same kind (that is, both nodes are discrete or both nodes are continuous).

select_state(state)

Selects the specified state of this Node.

This is equivalent to specifying the finding value 1 for the specified state and 0 for all other states.

set_alpha(alpha, i)

Sets the alpha component of the CG distribution of this continuous chance Node given the discrete parent configuration corresponding to i.

set_attribute(key, value)

Inserts the key/value pair in the attribute list for this Node. If the key is already defined, the value is updated. If no value is provided, the attribute is removed.

set_beta(beta, parent, i)

Sets the beta component of the CG distribution of this continuous chance Node given a continuous parent and the discrete parent configuration corresponding to i.

set_case_state(case_index, state)

Specify the state value of this discrete Node associated with case ‘case_index’.

set_case_value(case_index, value)

Set the value associated with this continuous Node in case ‘case_index’ to ‘value’.

set_category(category)

Set the category of this node. This node must be a discrete (chance or decision) node, and category must be CATEGORY.CHANCE or CATEGORY.DECISION.

set_edge_constraint(node, constraint=CONSTRAINT.NONE)

Sets a constraint between this Node and another Node.

set_gamma(gamma, i)

Sets the gamma component of the CG distribution of this continuous chance Node given the discrete parent configuration corresponding to i.

set_input(input, node)

This establishes an input binding: ‘node’ is the Node to be used as actual input for the formal input Node ‘input’ of the class of which this instance Node is an instance.

set_label(label)

Sets the label of this Node.

set_name(name)

Sets the name of this Node.

The name must be valid, i.e., it must follow the rules that govern the validity of C identifiers, and no other node in the network to which this Node belongs must have the same name.

set_number_of_states(count)

Sets the number of states of this node.

set_position(x, y)

Set the position of this Node to (x,y).

set_state_label(index, label)

Sets the label of the specified state.

set_state_value(state, value)

Sets the value associated with a particular state of this numbered node or the low value of the interval associated with a particular state of this interval node.

For interval nodes, to indicate the right endpoint of the rightmost interval, specify state equal to the number of states of this interval node.

substitute_class(new_cls)

Change the class of this instance Node to be an instance of the Class ‘new_cls’.

switch_parent(old_parent, new_parent)

Substitute new_parent for old_parent as a parent of this Node, while preserving the validity of the tables and model of this Node (all references to old_parent are replaced by references to new_parent). The old parent and new parent nodes must be ‘compatible’.

unset_case(index)

Specify that the value of this Node in specific case is unkown.

unset_input(input)

Delete the input binding (if any) for the input Node in this class instance Node.

class Model(owner, model_nodes=[])

A Model is a compact description of a table.

A model consists of a list of discrete nodes and a set of expressions (one expression per configuration of states of the nodes.

delete()

Deletes this Model.

get_expression(index)

Return the expression stored at position ‘index’ within this Model.

If no expression has been stored at the indicated position, None is returned.

get_nodes()

Retrieve the list of Nodes associated with this Model.

get_number_of_samples_per_interval()

Retrieve the count indicating the number of samples that would be used if a table were to be generated from this Model now.

get_size()

Returns the number of configurations of the Nodes of this Model.

is_alive()

Is this Model object alive?

set_expression(index, expression)

Store the expression (specified as a string) at position ‘index’ in this Model.

It is an error if index is out of range. If there is already an expression stored at the indicated position, then that expression is deleted.

set_number_of_samples_per_interval(count)

Specify that ‘count’ values should be sampled from each bounded interval of an interval parent when generating a table from model.

class Table(*_hhh156)

A potential is a function from the state space of a set of variables into the set of real numbers. The Table is a computer representation of a potential.

compute_probability_of_interval(x, y)

Compute the probability of the given interval for the mixture distribution represented by this Table.

The table must have been computed by Node.get_distribution().

delete()

Deletes this Table.

Tables owned by an application should be deleted using this method.

get_cg_size()

Returns the CG size of this Table. This is the number of CG data elements stored in the table.

get_configuration(index)

Computes the state configuration corresponding to a given table index.

The computed state configuration is returned as a tuple of state indices: The state index for the k’th node in the node list (see the get_nodes() function) of this Table (if the node is discrete) is stored in the k’th entry of the tuple.

get_covariance(i, node1, node2)

Returns the covariance of a couple of continuous chance Nodes given a configuration of the discrete chance Nodes of this Table.

get_data(data=None, start=None, count=None)

Return a copy of the discrete data of this Table. Since this is a copy of the real data stored in the table, updates will only take place when the data is copied back using the set_data() method.

Note: When invoked with no arguments, returns a new list containing a copy of the entire table.

When invoked with arguments, returns a region of the data of this Table. The data is copied to the ‘data’ list. The region is specified by a ‘start’ position and the number of elements ‘count’ to copy (it is required that the ‘data’ list must be of size >= ‘count’).

get_index(configuration)

Computes the table index corresponding to a given state configuration.

The state configuration is specified in the configuration list: A state index for the k’th node in the node list (see the get_nodes() function) of this Table (if the node is discrete) must be specified in the k’th entry of the array. The length of the configuration must match the number of discrete nodes of this Table.

get_mean(i, node)

Returns the mean of a continuous chance Node given a configuration of the discrete chance Nodes of this Table.

get_nodes()

Retrieve the list of Nodes associated with this Table.

get_size()

Returns the size of this Table.

get_variance(i, node)

Return the variance of the conditional distribution of a continuous Node given the discrete state configuration i.

is_alive()

Is this Table object alive?

reorder_nodes(order)

Reorder the node list of table to be order (the contents of the data arrays are reorganized according to the new node order).

set_data(data, start=None, count=None)

Sets the discrete data of this Table. The contents of the ‘data’ list are copied to the table.

Note: When invoked with only the ‘data’ argument, copies all values from the ‘data’ list to this table. The size of the list must equal the size of the table.

When also invoked with the ‘start’ and ‘count’ arguments, sets a region of the discrete data of this Table. The region is specified by a ‘start’ position and the number of elements ‘count’ to copy. The data is copied from the data list to the table. (The indexes ‘start’, …, ‘start’+’count’-1 must be valid indexes of this Table. Also, ‘count’ must be less than or equal to the size of the ‘data’ list).

class DataSet(*_hhh156)

The DataSet class represents a data set as a ‘matrix’ with cases as rows and variables as columns.

compute_iem_intervals(value_column, class_column)

Create a discretization of the numeric data in the specified column. The supervised discretization algorithm by Fayyad and Irani is used to create intervals for the numeric data in the column with index value_column. The class data used to guide the discretization is contained in the column with index class_column.

delete()

Deletes this DataSet.

delete_column(column)

Delete the specified column from this DataSet.

Columns to the right of the deleted column are shifted one position to the left.

delete_row(row)

Delete the specified row from this DataSet.

Rows below the deleted row are shifted one position up.

get_column_name(column)

Return the data item stored at the specified location of this DataSet.

If there is no data item (i.e., the data item is ‘missing’) at the specified location, None is returned.

get_data_item(row, column)

Return the data item stored at the specified location of this DataSet.

If there is no data item (i.e., the data item is ‘missing’) at the specified location, None is returned.

get_number_of_columns()

Return the number of columns in this DataSet.

get_number_of_rows()

Return the number of rows in this DataSet.

is_alive()

Is this DataSet object alive?

move_column(column, new_column)

Move the specified column to a new position.

The columns between the old and the new column positions are shifted one position to the left or to the right depending on the direction of the move.

move_row(row, new_row)

Move the specified row to a new position.

The rows between the old and the new row positions are shifted one position up or down depending on the direction of the move.

new_column(name)

Create a new (empty) column in data set named name.

The name can be any text string, but if it should later be used as the name of a node, then the usual requirements for node names must be satisfied.

The index associated with the new column is returned.

new_row()

Create a new (empty) row in this DataSet. The index associated with the new row is returned.

static parse_data_set(csv_string_or_file_name, separator=', ', error_handler=None)

Construct a DataSet from a CSV specification provided in a file or as a string.

Instead of a comma, a different separator character may be used.

save(file_name, separator=', ')

Save this DataSet in the format of a comma-separated-values (CSV) file.

However, a different delimiter than a comma may be used.

set_column_name(column, name)

Change the name of the specified column of this DataSet to ‘name’.

set_data_item(row, column, data)

Set (or delete) the data item at the specified location of this DataSet.

If ‘data’ is None , then the value at the specified location is deleted (indicating a ‘missing’ data item).

to_csv_string(separator=', ')

Create a CSV representation (as a string) of this DataSet.

class CATEGORY

The CATEGORY is used to attach a category tag to the Nodes of Classes and Domains.

Values:

CATEGORY.FUNCTION

CATEGORY.INSTANCE

CATEGORY.CHANCE

CATEGORY.DECISION

CATEGORY.UTILITY

CHANCE = CATEGORY.CHANCE
DECISION = CATEGORY.DECISION
FUNCTION = CATEGORY.FUNCTION
INSTANCE = CATEGORY.INSTANCE
UTILITY = CATEGORY.UTILITY
class KIND

The KIND is used to attach a sub-category tag to the chance and decision nodes of Classes and Domains.

Values:

KIND.OTHER

KIND.DISCRETE

KIND.CONTINUOUS

CONTINUOUS = KIND.CONTINUOUS
DISCRETE = KIND.DISCRETE
OTHER = KIND.OTHER
class SUBTYPE

The SUBTYPE is used to classify the four subtypes for discrete nodes.

Values:

SUBTYPE.LABEL

SUBTYPE.BOOLEAN

SUBTYPE.NUMBER

SUBTYPE.INTERVAL

BOOLEAN = SUBTYPE.BOOLEAN
INTERVAL = SUBTYPE.INTERVAL
LABEL = SUBTYPE.LABEL
NUMBER = SUBTYPE.NUMBER
class TRIANGULATION_METHOD

The TRIANGULATION_METHOD represents the triangulation method used in a Domain.

Values:

TRIANGULATION_METHOD.CLIQUE_SIZE

TRIANGULATION_METHOD.CLIQUE_WEIGHT

TRIANGULATION_METHOD.FILL_IN_SIZE

TRIANGULATION_METHOD.FILL_IN_WEIGHT

TRIANGULATION_METHOD.TOTAL_WEIGHT

TRIANGULATION_METHOD.BEST_GREEDY

BEST_GREEDY = TRIANGULATION_METHOD.BEST_GREEDY
CLIQUE_SIZE = TRIANGULATION_METHOD.CLIQUE_SIZE
CLIQUE_WEIGHT = TRIANGULATION_METHOD.CLIQUE_WEIGHT
FILL_IN_SIZE = TRIANGULATION_METHOD.FILL_IN_SIZE
FILL_IN_WEIGHT = TRIANGULATION_METHOD.FILL_IN_WEIGHT
TOTAL_WEIGHT = TRIANGULATION_METHOD.TOTAL_WEIGHT
class EQUILIBRIUM

The EQUILIBRIUM represents the equilibrium state of a Domain.

Values:

EQUILIBRIUM.NONE

EQUILIBRIUM.SUM

EQUILIBRIUM.MAX

MAX = EQUILIBRIUM.MAX
NONE = EQUILIBRIUM.NONE
SUM = EQUILIBRIUM.SUM
class EVIDENCE_MODE

The EVIDENCE_MODE represents the mode used for propagating evidence in a Domain.

Values:

EVIDENCE_MODE.NORMAL

EVIDENCE_MODE.FAST_RETRACTION

FAST_RETRACTION = EVIDENCE_MODE.FAST_RETRACTION
NORMAL = EVIDENCE_MODE.NORMAL
class CONSTRAINT

The CONSTRAINT class is used to represent possible domain knowledge about a particular edge between a pair of variables. Such knowledge can be used to constrain the set of networks that can be learned from data. The knowledge is used by the learning algorithm to resolve ambiguities (e.g., deciding the direction of a edge). Concretely, the knowledge can express the direction of a edge, the presence or absence of a edge, or both.

Values:

CONSTRAINT.NONE

CONSTRAINT.EDGE_REQUIRED

CONSTRAINT.FORWARD_EDGE_REQUIRED

CONSTRAINT.BACKWARD_EDGE_REQUIRED

CONSTRAINT.EDGE_FORBIDDEN

CONSTRAINT.FORWARD_EDGE_FORBIDDEN

CONSTRAINT.BACKWARD_EDGE_FORBIDDEN

BACKWARD_EDGE_FORBIDDEN = CONSTRAINT.BACKWARD_EDGE_FORBIDDEN
BACKWARD_EDGE_REQUIRED = CONSTRAINT.BACKWARD_EDGE_REQUIRED
EDGE_FORBIDDEN = CONSTRAINT.EDGE_FORBIDDEN
EDGE_REQUIRED = CONSTRAINT.EDGE_REQUIRED
FORWARD_EDGE_FORBIDDEN = CONSTRAINT.FORWARD_EDGE_FORBIDDEN
FORWARD_EDGE_REQUIRED = CONSTRAINT.FORWARD_EDGE_REQUIRED
NONE = CONSTRAINT.NONE