Quantum Fog  0.9.3
Public Member Functions | List of all members
learning.ChowLiuTreeLner.ChowLiuTreeLner Class Reference
Inheritance diagram for learning.ChowLiuTreeLner.ChowLiuTreeLner:
Inheritance graph
[legend]
Collaboration diagram for learning.ChowLiuTreeLner.ChowLiuTreeLner:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, states_df, vtx_to_states=None)
 
def learn_net_struc (self)
 
def prune_ew_list (self, mi_array, ew_list)
 
def do_if_both_nds_old (self, j, k, nd_ids)
 
- Public Member Functions inherited from learning.NetStrucLner.NetStrucLner
def __init__ (self, is_quantum, states_df, vtx_to_states=None)
 
def fill_bnet_with_parents (self, vtx_to_parents)
 

Additional Inherited Members

- Static Public Member Functions inherited from learning.NetStrucLner.NetStrucLner
def learn_nd_state_names (bnet, states_df)
 
def import_nd_state_names (bnet, vtx_to_states)
 
def int_sts_detector (sub_states_df)
 
- Public Attributes inherited from learning.NetStrucLner.NetStrucLner
 is_quantum
 
 bnet
 
 states_df
 
 ord_nodes
 

Detailed Description

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.

Constructor & Destructor Documentation

def learning.ChowLiuTreeLner.ChowLiuTreeLner.__init__ (   self,
  states_df,
  vtx_to_states = None 
)
Constructor

Parameters
----------
states_df : pandas.DataFrame
vtx_to_states : dict[str, list[str]]
    A dictionary mapping each node name to a list of its state names.
    This information will be stored in self.bnet. If
    vtx_to_states=None, constructor will learn vtx_to_states
    from states_df

Returns
-------
None

Member Function Documentation

def learning.ChowLiuTreeLner.ChowLiuTreeLner.do_if_both_nds_old (   self,
  j,
  k,
  nd_ids 
)
This function processes the case when j and k are both old, i.e.,
have been visited already. For this class, it does nothing, which is
why this class learns only trees.

Parameters
----------
j : int
k : int
nd_ids : list[int]

Returns
-------
None
def learning.ChowLiuTreeLner.ChowLiuTreeLner.learn_net_struc (   self)
Learns the net structure (i.e., it learns the children of each node)

Returns
-------
None
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)]

The documentation for this class was generated from the following file: