本文整理汇总了Python中libpgm.nodedata.NodeData.entriestoinstances方法的典型用法代码示例。如果您正苦于以下问题:Python NodeData.entriestoinstances方法的具体用法?Python NodeData.entriestoinstances怎么用?Python NodeData.entriestoinstances使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libpgm.nodedata.NodeData
的用法示例。
在下文中一共展示了NodeData.entriestoinstances方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestNodeData
# 需要导入模块: from libpgm.nodedata import NodeData [as 别名]
# 或者: from libpgm.nodedata.NodeData import entriestoinstances [as 别名]
class TestNodeData(unittest.TestCase):
def setUp(self):
self.nd = NodeData()
def test_entriestoinstances(self):
self.nd.load("unittesthdict.txt")
self.nd.entriestoinstances()
result = self.nd.nodes["Intelligence"].choose([])
self.assertTrue(result == 'low' or result == 'high')
示例2: TestHyBayesianNetwork
# 需要导入模块: from libpgm.nodedata import NodeData [as 别名]
# 或者: from libpgm.nodedata.NodeData import entriestoinstances [as 别名]
class TestHyBayesianNetwork(unittest.TestCase):
def setUp(self):
self.nd = NodeData()
self.nd.load("unittesthdict.txt")
self.nd.entriestoinstances()
self.skel = GraphSkeleton()
self.skel.load("unittestdict.txt")
self.skel.toporder()
self.hybn = HyBayesianNetwork(self.skel, self.nd)
def test_randomsample(self):
sample = self.hybn.randomsample(1)[0]
self.assertTrue(isinstance(sample['Grade'], float))
self.assertTrue(isinstance(sample['Intelligence'], str))
self.assertEqual(sample["SAT"][-12:], 'blueberries!')
示例3: hybrid
# 需要导入模块: from libpgm.nodedata import NodeData [as 别名]
# 或者: from libpgm.nodedata.NodeData import entriestoinstances [as 别名]
#print json.dumps(result, indent=2)
# (3) ----------------------------------------------------------------------
# Generate a sequence of samples from a hybrid (any CPD type) Bayesian network.
# load nodedata and graphskeleton
nd = NodeData()
skel = GraphSkeleton()
nd.load("../tests/unittesthdict.txt")
skel.load("../tests/unittestdict.txt")
# topologically order graphskeleton
skel.toporder()
# convert nodes to class instances
nd.entriestoinstances()
# load bayesian network
hybn = HyBayesianNetwork(skel, nd)
# sample
result = hybn.randomsample(10)
# output - toggle comment to see
#print json.dumps(result, indent=2)
# (4) ------------------------------------------------------------------------
# Generate a sequence of samples from a discrete-CPD Bayesian network, given evidence
# load nodedata and graphskeleton
nd = NodeData()