MCPcopy Create free account
hub / github.com/CyberPoint/libpgm / __init__

Method __init__

libpgm/tablecpdfactorization.py:41–59  ·  view source on GitHub ↗

This class is constructed with a :doc:`DiscreteBayesianNetwork ` instance as argument. First, it takes the input itself and stores it in the *bn* attribute. Then, it transforms the information of each of these nodes from standard discrete CPD form into a :doc:`Table

(self, bn)

Source from the content-addressed store, hash-verified

39 '''
40
41 def __init__(self, bn):
42 '''
43 This class is constructed with a :doc:`DiscreteBayesianNetwork <discretebayesiannetwork>` instance as argument. First, it takes the input itself and stores it in the *bn* attribute. Then, it transforms the information of each of these nodes from standard discrete CPD form into a :doc:`TableCPDFactor <tablecpdfactor>` isntance and stores the instances in an array in the attribute *originalfactorlist*. Finally, it makes a copy of this list to work with and stores it in *factorlist*.
44
45 ''&#x27;
46 assert hasattr(bn, "V") and hasattr(bn, "E") and hasattr(bn, "Vdata"), \
47 "Input must be a DiscreteBayesianNetwork instance."
48
49 self.bn = bn
50 '''The Bayesian network used as argument at instantiation.'''
51 self.originalfactorlist = []
52 '''A list of :doc:`TableCPDFactor <tablecpdfactor>` instances, one per node.'''
53 for vertex in bn.V:
54 factor = TableCPDFactor(vertex, bn)
55 self.originalfactorlist.append(factor)
56 self.factorlist = copy.deepcopy(self.originalfactorlist)
57 '''A working copy of *originalfactorlist*.'''
58
59 assert self.factorlist, "Factor list not properly loaded, check for an incomplete class instance as input."
60
61 def refresh(self):
62 ''&#x27;

Callers

nothing calls this directly

Calls 1

TableCPDFactorClass · 0.90

Tested by

no test coverage detected