![]() |
Quantum Fog
0.9.3
|


Public Member Functions | |
| def | __init__ (self, states_df, alpha, verbose=False, vtx_to_states=None, learn_later=False) |
| def | find_nbors (self) |
| def | find_PC (self, vtx=None) |
| def | find_MB (self, vtx=None) |
Public Member Functions inherited from learning.MB_BasedLner.MB_BasedLner | |
| def | __init__ (self, states_df, alpha, verbose=False, vtx_to_states=None, learn_later=False) |
| def | learn_struc (self) |
| def | find_MB (self, vtx=None) |
| def | find_nbors (self) |
| def | orient_edges (self) |
| def | new_filled_nx_graph (self) |
| def | undo_cycles (self) |
| def | orient_undecided_edges (self) |
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) |
Public Attributes | |
| vtx_to_nbors | |
| vtx_to_MB | |
Public Attributes inherited from learning.MB_BasedLner.MB_BasedLner | |
| alpha | |
| verbose | |
| vtx_to_MB | |
| vtx_to_parents | |
| vtx_to_nbors | |
Public Attributes inherited from learning.NetStrucLner.NetStrucLner | |
| is_quantum | |
| bnet | |
| states_df | |
| ord_nodes | |
Additional Inherited Members | |
Static Public Member Functions inherited from learning.MB_BasedLner.MB_BasedLner | |
| def | MB_lner_test (LnerClass, verbose=False) |
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) |
The MMPCLner (Min Max Parents Children Learner) is a subclass of
MB_BasedLner. See docstring for MB_BasedLner for more info about this
type of algo.
Whereas the first generation of MB_ algos found the MB of each node
first and the neighbors of each node second, the MMPC algorithm finds
these in the opposite order.
PC stands for Parents-Children. The PC set of a node is the same thing as
its set of neighbors.
See Shunkai Fu Thesis for pseudo code on which this class is based.
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.
alpha : float
threshold used for deciding whether a conditional or unconditional
mutual info is said to be close to zero (independence) or not (
dependence). The error in a data entropy is on the order of ln(n+1)
- ln(n) \approx 1/n where n is the number of samples so 5/n is a
good default value for alpha.
verbose : bool
True for this prints a running commentary to console
vtx_to_MB : dict[str, list[str]]
A dictionary mapping each vertex to a list of the vertices in its
Markov Blanket. (The MB of a node consists of its parents, children
and children's parents, aka spouses).
vtx_to_nbors : dict[str, list[str]]
a dictionary mapping each vertex to a list of its neighbors. The
literature also calls the set of neighbors of a vertex its PC (
parents-children) set.
vtx_to_parents : dict[str, list[str]]
dictionary mapping each vertex to a list of its parents's names | def learning.MB_MMPC_Lner.MB_MMPC_Lner.__init__ | ( | self, | |
| states_df, | |||
| alpha, | |||
verbose = False, |
|||
vtx_to_states = None, |
|||
learn_later = False |
|||
| ) |
Constructor
Parameters
----------
states_df : pandas.DatFrame
alpha : float
verbose : bool
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
learn_later : bool
False if you want to call the function learn_struc() inside the
constructor. True if not.
Returns
-------
None
| def learning.MB_MMPC_Lner.MB_MMPC_Lner.find_MB | ( | self, | |
vtx = None |
|||
| ) |
This function finds the MB of vtx and stores it inside vtx_to_MB[ vtx]. If vtx=None, then it will find the MB of all the vertices of the graph. Parameters ---------- vtx : str Returns ------- None
| def learning.MB_MMPC_Lner.MB_MMPC_Lner.find_nbors | ( | self | ) |
This function is called in the parent class MB_BasedLner after the function find_MB() is. But in this subclass we want to find the neighbors before finding the MBs. We solve this quandary by overriding find_nbors() so that it does nothing, and defining a new function find_PC() that also finds the neighbors, but is called inside find_MB(). In MB_BasedLner, the function find_nbors() assumes that the MB of all nodes is known whereas in this subclass, the function find_PC() doesn't assume this. Returns ------- None
| def learning.MB_MMPC_Lner.MB_MMPC_Lner.find_PC | ( | self, | |
vtx = None |
|||
| ) |
This function finds the PC set (Parents-Children, aka neighbors) of vtx and stores it in vtx_to_nbors. if vtx=None, it finds the PC set of all nodes. Parameters ---------- vtx : str Returns ------- None
1.8.11