ChowLiuTreeLnr (Chow Liu Tree Learner) is a subclass of NetStrucLner. It
learns a Chow Liu tree from a dataframe states_df. See Wikipedia for a
description of CL trees and original references.
In a CL tree, the root node has several children and each of those can
have children and so on. Each child has a single unisex parent.
The arrows must branch out rather than merge because, by definition,
the probability of each node (except the root nodes) of a CL tree must
be of the form P(b|a) where b and a are single nodes. i.e., each node
must have a single parent. This is not the case if two arrows merge at a
node.
Each arrow is assigned the empirical mutual information (MI) between the
nodes it connects. The MI decreases as one moves away from the root node.
Even if the input dataframe is generated from a tree, the learned tree
structure will not necessarily look like the original tree.
References
----------
1. Nicholas Cullen neuroBN at github
Attributes
----------
is_quantum : bool
True for quantum bnets amd False for classical bnets
bnet : BayesNet
a BayesNet in which we store what is learned
states_df : pandas.DataFrame
a Pandas DataFrame with training data. column = node and row =
sample. Each row/sample gives the state of the col/node.
ord_nodes : list[DirectedNode]
a list of DirectedNode's named and in the same order as the column
labels of self.states_df.
def learning.ChowLiuTreeLner.ChowLiuTreeLner.prune_ew_list |
( |
|
self, |
|
|
|
mi_array, |
|
|
|
ew_list |
|
) |
| |
This function takes as input an ew_list and returns that list pruned
(i.e., with some of its items removed). In this class, it does no
pruning but for subclasses like AracneLner it does.
Parameters
----------
mi_array : numpy.array
a square array with the mutual information of nodes i and j at
position (i, j) of the array, with i < j.
ew_list : list[tuple[int, int, float]]
an edge-weight (ew) list. An ew is a 3-tuple ( i, j, weight)
representing an arrow i->j for ints i, j denoting vertices,
with weight w equal to the mutual info between the two endpoints
i, j of the arrow.
Returns
-------
list[tuple(int, int, float)]