本文整理汇总了Python中libpgm.nodedata.NodeData.Vdata方法的典型用法代码示例。如果您正苦于以下问题:Python NodeData.Vdata方法的具体用法?Python NodeData.Vdata怎么用?Python NodeData.Vdata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libpgm.nodedata.NodeData
的用法示例。
在下文中一共展示了NodeData.Vdata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: q_without_ros
# 需要导入模块: from libpgm.nodedata import NodeData [as 别名]
# 或者: from libpgm.nodedata.NodeData import Vdata [as 别名]
def q_without_ros():
skel = GraphSkeleton()
skel.V = ["prize_door", "guest_door", "monty_door"]
skel.E = [["prize_door", "monty_door"],
["guest_door", "monty_door"]]
skel.toporder()
nd = NodeData()
nd.Vdata = {
"prize_door": {
"numoutcomes": 3,
"parents": None,
"children": ["monty_door"],
"vals": ["A", "B", "C"],
"cprob": [1.0/3, 1.0/3, 1.0/3],
},
"guest_door": {
"numoutcomes": 3,
"parents": None,
"children": ["monty_door"],
"vals": ["A", "B", "C"],
"cprob": [1.0/3, 1.0/3, 1.0/3],
},
"monty_door": {
"numoutcomes": 3,
"parents": ["prize_door", "guest_door"],
"children": None,
"vals": ["A", "B", "C"],
"cprob": {
"['A', 'A']": [0., 0.5, 0.5],
"['B', 'B']": [0.5, 0., 0.5],
"['C', 'C']": [0.5, 0.5, 0.],
"['A', 'B']": [0., 0., 1.],
"['A', 'C']": [0., 1., 0.],
"['B', 'A']": [0., 0., 1.],
"['B', 'C']": [1., 0., 0.],
"['C', 'A']": [0., 1., 0.],
"['C', 'B']": [1., 0., 0.],
},
},
}
bn = DiscreteBayesianNetwork(skel, nd)
fn = TableCPDFactorization(bn)
query = {
"prize_door": ["A","B","C"],
}
evidence = {
"guest_door": "A",
"monty_door": "B",
}
res = fn.condprobve(query, evidence)
print res.vals
print res.scope
print res.card
print res.stride
示例2: discrete_nodedata_from_ros
# 需要导入模块: from libpgm.nodedata import NodeData [as 别名]
# 或者: from libpgm.nodedata.NodeData import Vdata [as 别名]
def discrete_nodedata_from_ros(nodes):
nd = NodeData()
nd.Vdata = {n.name: dict_from_ros_discrete_node(n) for n in nodes}
return nd