本文整理汇总了Python中pyds.MassFunction.max_bel方法的典型用法代码示例。如果您正苦于以下问题:Python MassFunction.max_bel方法的具体用法?Python MassFunction.max_bel怎么用?Python MassFunction.max_bel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyds.MassFunction
的用法示例。
在下文中一共展示了MassFunction.max_bel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PyDSTest
# 需要导入模块: from pyds import MassFunction [as 别名]
# 或者: from pyds.MassFunction import max_bel [as 别名]
#.........这里部分代码省略.........
test(MassFunction.gbt(pl, sample_count=10000), 2)
#pl = [('a', 0.3), ('b', 0.8), ('c', 0.0), ('d', 1.0)]
pl = {'a':0.3, 'b':0.8, 'c':0.0, 'd':1.0}
self._assert_equal_belief(MassFunction.gbt(pl), MassFunction.gbt(pl, sample_count=10000), 2)
def test_frame(self):
self.assertEqual({'a', 'b', 'c', 'd'}, self.m1.frame())
self.assertEqual({'a', 'b', 'c'}, self.m2.frame())
self.assertEqual(set(), MassFunction().frame())
def test_singletons(self):
self.assertSetEqual({frozenset('a'), frozenset('b'), frozenset('c'), frozenset('d')}, self.m1.singletons())
def test_focal(self):
self.assertEqual(4, len(list(self.m1.focal())))
for f in self.m1.focal():
self.assertTrue(f in self.m1, f)
self.m1[{'b'}] = 0
self.assertEqual(3, len(self.m1.focal()))
self.assertFalse({'b'} in self.m1.focal())
def test_core(self):
self.assertEqual({'a', 'b', 'c', 'd'}, self.m1.core())
self.m1[{'a', 'b', 'c', 'd'}] = 0
self.assertEqual({'a', 'b', 'd'}, self.m1.core())
self.assertEqual(set(), MassFunction().core())
# test combined core
self.assertEqual({'a', 'b'}, self.m1.core(self.m2))
def test_all(self):
all = {frozenset(), frozenset('a'), frozenset('b'), frozenset('ab')}
self.assertSetEqual(all, set(MassFunction({'a':0.1, 'b':0}).all()))
def test_max_bel(self):
self.assertEqual(frozenset('a'), self.m1.max_bel())
self.assertEqual(frozenset('c'), self.m3.max_bel())
self.assertTrue(MassFunction({('ab'):1}).max_bel() in {frozenset('a'), frozenset('b')})
def test_max_pl(self):
self.assertEqual(frozenset('a'), self.m1.max_pl())
self.assertEqual(frozenset('c'), self.m3.max_pl())
self.assertTrue(MassFunction({('ab'):0.8, 'c':0.2}).max_pl() in {frozenset('a'), frozenset('b')})
def test_combine_gbt(self):
pl = [('b', 0.8), ('c', 0.5)]
correct = self.m1.combine_conjunctive(MassFunction.gbt(pl))
self._assert_equal_belief(correct, self.m1.combine_gbt(pl), 10)
self._assert_equal_belief(self.m1.combine_gbt(pl), self.m1.combine_gbt(pl, sample_count=10000), 1)
self._assert_equal_belief(self.m2.combine_gbt(pl), self.m2.combine_gbt(pl, sample_count=10000), 1)
# Bayesian special case
p_prior = self.m1.pignistic()
p_posterior = p_prior.combine_gbt(pl)
p_correct = MassFunction()
for s, l in pl:
p_correct[(s,)] = l * p_prior[(s,)]
p_correct.normalize()
self._assert_equal_belief(p_correct, p_posterior, 10)
def test_is_probabilistic(self):
self.assertFalse(self.m1.is_probabilistic())
self.assertTrue(self.m1.pignistic().is_probabilistic())
for p in self.m1.sample_probability_distributions(100):
self.assertTrue(p.is_probabilistic())
def test_sample_probability_distributions(self):
for p in self.m1.sample_probability_distributions(100):