当前位置: 首页>>代码示例>>Python>>正文


Python MassFunction.combine_disjunctive方法代码示例

本文整理汇总了Python中pyds.MassFunction.combine_disjunctive方法的典型用法代码示例。如果您正苦于以下问题:Python MassFunction.combine_disjunctive方法的具体用法?Python MassFunction.combine_disjunctive怎么用?Python MassFunction.combine_disjunctive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyds.MassFunction的用法示例。


在下文中一共展示了MassFunction.combine_disjunctive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: print

# 需要导入模块: from pyds import MassFunction [as 别名]
# 或者: from pyds.MassFunction import combine_disjunctive [as 别名]
print('\n=== Dempster\'s combination rule, unnormalized conjunctive combination (exact and approximate) ===')
print('Dempster\'s combination rule for m_1 and m_2 =', m1 & m2)
print('Dempster\'s combination rule for m_1 and m_2 (Monte-Carlo, importance sampling) =', m1.combine_conjunctive(m2, sample_count=1000, importance_sampling=True))
print('Dempster\'s combination rule for m_1, m_2, and m_3 =', m1.combine_conjunctive(m2, m3))
print('unnormalized conjunctive combination of m_1 and m_2 =', m1.combine_conjunctive(m2, normalization=False))
print('unnormalized conjunctive combination of m_1 and m_2 (Monte-Carlo) =', m1.combine_conjunctive(m2, normalization=False, sample_count=1000))
print('unnormalized conjunctive combination of m_1, m_2, and m_3 =', m1.combine_conjunctive(m2, m3, normalization=False))

print('\n=== normalized and unnormalized conditioning ===')
print('normalized conditioning of m_1 with {a, b} =', m1.condition({'a', 'b'}))
print('unnormalized conditioning of m_1 with {b, c} =', m1.condition({'b', 'c'}, normalization=False))

print('\n=== disjunctive combination rule (exact and approximate) ===')
print('disjunctive combination of m_1 and m_2 =', m1 | m2)
print('disjunctive combination of m_1 and m_2 (Monte-Carlo) =', m1.combine_disjunctive(m2, sample_count=1000))
print('disjunctive combination of m_1, m_2, and m_3 =', m1.combine_disjunctive(m2, m3))

print('\n=== weight of conflict ===')
print('weight of conflict between m_1 and m_2 =', m1.conflict(m2))
print('weight of conflict between m_1 and m_2 (Monte-Carlo) =', m1.conflict(m2, sample_count=1000))
print('weight of conflict between m_1, m_2, and m_3 =', m1.conflict(m2, m3))

print('\n=== pignistic transformation ===')
print('pignistic transformation of m_1 =', m1.pignistic())
print('pignistic transformation of m_2 =', m2.pignistic())
print('pignistic transformation of m_3 =', m3.pignistic())

print('\n=== local conflict uncertainty measure ===')
print('local conflict of m_1 =', m1.local_conflict())
print('entropy of the pignistic transformation of m_3 =', m3.pignistic().local_conflict())
开发者ID:aginor,项目名称:pyds,代码行数:32,代码来源:examples.py

示例2: PyDSTest

# 需要导入模块: from pyds import MassFunction [as 别名]
# 或者: from pyds.MassFunction import combine_disjunctive [as 别名]

#.........这里部分代码省略.........
        self.assertEqual(0.4, m1_un['ad'])
        m3 = self.m3.condition('ac')
        self.assertEqual(0.5, m3['ac'])
        self.assertAlmostEqual(1.0 / 3.0, m3['c'])
        self.assertAlmostEqual(1.0 / 6.0, m3['a'])
        m3_un = self.m3.condition('ab', normalization=False)
        self.assertAlmostEqual(0.6, m3_un[set()])
        self.assertEqual(0.3, m3_un['a'])
        self.assertEqual(0.1, m3_un['ab'])
    
    def test_combine_conjunctive(self):
        def test(m, empty_mass, places=10):
            self.assertAlmostEqual(empty_mass, m[set()], places)
            norm = 0.55 + empty_mass
            self.assertAlmostEqual(0.15 / norm, m['a'], places)
            self.assertAlmostEqual(0.25 / norm, m['b'], places)
            self.assertAlmostEqual(0.06 / norm, m['c'], places)
            self.assertAlmostEqual(0.09 / norm, m['ac'], places)
        # normalized
        test(self.m1 & self.m2, 0.0)
        test(self.m1.combine_conjunctive(self.m2, sample_count=10000), 0.0, 1)
        test(self.m1.combine_conjunctive(self.m2, sample_count=1000, importance_sampling=True), 0.0)
        # unnormalized
        test(self.m1.combine_conjunctive(self.m2, normalization=False), 0.45)
        test(self.m1.combine_conjunctive(self.m2, normalization=False, sample_count=10000), 0.45, 2)
        test(self.m1.combine_conjunctive(self.m2, normalization=False, sample_count=1000, importance_sampling=True), 0.45, 2) # ImpSam should be ignored
        # combine multiple mass functions
        m_single = self.m1.combine_conjunctive(self.m1).combine_conjunctive(self.m2)
        m_multi = self.m1.combine_conjunctive(self.m1, self.m2)
        self._assert_equal_belief(m_single, m_multi, 10)
        # combine incompatible mass function
        self.assertFalse(self.m1 & MassFunction({(0, 1):0.8, (0,):0.2}))
    
    def test_combine_disjunctive(self):
        def test(m, places):
            self.assertAlmostEqual(0.2, m['ab'], places)
            self.assertAlmostEqual(0.2, m['ac'], places)
            self.assertAlmostEqual(0.1, m['b'], places)
            self.assertAlmostEqual(0.04, m['bc'], places)
            self.assertAlmostEqual(0.06, m['abc'], places)
            self.assertAlmostEqual(0.05, m['abd'], places)
            self.assertAlmostEqual(0.05, m['acd'], places)
            self.assertAlmostEqual(0.3, m['abcd'], places)
        test(self.m1 | self.m2, 10)
        test(self.m1.combine_disjunctive(self.m2, sample_count=10000), 2)
        # combine multiple mass functions
        m_single = self.m1.combine_disjunctive(self.m1).combine_disjunctive(self.m2)
        m_multi = self.m1.combine_disjunctive(self.m1, self.m2)
        for h, v in m_single.items():
            self.assertAlmostEqual(v, m_multi[h])
    
    def test_conflict(self):
        self.assertEqual(-log(0.55, 2), self.m1.conflict(self.m2));
        self.assertAlmostEqual(-log(0.55, 2), self.m1.conflict(self.m2, sample_count=1000), 1);
        self.assertEqual(float('inf'), self.m1.conflict(MassFunction({'e': 1})));
    
    def test_normalize(self):
        v = self.m1['a']
        del self.m1['a']
        self.m1.normalize()
        self.assertAlmostEqual(0.2 / (1 - v), self.m1['b'])
        self.assertAlmostEqual(0.1 / (1 - v), self.m1['ad'])
        self.assertAlmostEqual(0.3 / (1 - v), self.m1['abcd'])
        self.assertEqual(0, len(MassFunction().normalize()))
    
    def test_multiple_dimensions(self):
开发者ID:aginor,项目名称:pyds,代码行数:70,代码来源:pyds_test.py

示例3: PyDSTest

# 需要导入模块: from pyds import MassFunction [as 别名]
# 或者: from pyds.MassFunction import combine_disjunctive [as 别名]

#.........这里部分代码省略.........
        self.assertEqual(0.4, m1_un['ad'])
        m3 = self.m3.condition('ac')
        self.assertEqual(0.5, m3['ac'])
        self.assertAlmostEqual(1.0 / 3.0, m3['c'])
        self.assertAlmostEqual(1.0 / 6.0, m3['a'])
        m3_un = self.m3.condition('ab', normalization=False)
        self.assertAlmostEqual(0.6, m3_un[set()])
        self.assertEqual(0.3, m3_un['a'])
        self.assertEqual(0.1, m3_un['ab'])
    
    def test_combine_conjunctive(self):
        def test(m, empty_mass, places=10):
            self.assertAlmostEqual(empty_mass, m[set()], places)
            norm = 0.55 + empty_mass
            self.assertAlmostEqual(0.15 / norm, m['a'], places)
            self.assertAlmostEqual(0.25 / norm, m['b'], places)
            self.assertAlmostEqual(0.06 / norm, m['c'], places)
            self.assertAlmostEqual(0.09 / norm, m['ac'], places)
        # normalized
        test(self.m1 & self.m2, 0.0)
        test(self.m1.combine_conjunctive(self.m2, sample_count=10000), 0.0, 1)
        test(self.m1.combine_conjunctive(self.m2, sample_count=1000, importance_sampling=True), 0.0)
        # unnormalized
        test(self.m1.combine_conjunctive(self.m2, normalization=False), 0.45)
        test(self.m1.combine_conjunctive(self.m2, normalization=False, sample_count=10000), 0.45, 2)
        test(self.m1.combine_conjunctive(self.m2, normalization=False, sample_count=1000, importance_sampling=True), 0.45, 2) # ImpSam should be ignored
        # combine multiple mass functions
        m_single = self.m1.combine_conjunctive(self.m1).combine_conjunctive(self.m2)
        m_multi = self.m1.combine_conjunctive(self.m1, self.m2)
        self._assert_equal_belief(m_single, m_multi, 10)
        # combine incompatible mass function
        self.assertFalse(self.m1 & MassFunction({(0, 1):0.8, (0,):0.2}))
    
    def test_combine_disjunctive(self):
        def test(m, places):
            self.assertAlmostEqual(0.2, m['ab'], places)
            self.assertAlmostEqual(0.2, m['ac'], places)
            self.assertAlmostEqual(0.1, m['b'], places)
            self.assertAlmostEqual(0.04, m['bc'], places)
            self.assertAlmostEqual(0.06, m['abc'], places)
            self.assertAlmostEqual(0.05, m['abd'], places)
            self.assertAlmostEqual(0.05, m['acd'], places)
            self.assertAlmostEqual(0.3, m['abcd'], places)
        test(self.m1 | self.m2, 10)
        test(self.m1.combine_disjunctive(self.m2, sample_count=10000), 2)
        # combine multiple mass functions
        m_single = self.m1.combine_disjunctive(self.m1).combine_disjunctive(self.m2)
        m_multi = self.m1.combine_disjunctive(self.m1, self.m2)
        for h, v in m_single.items():
            self.assertAlmostEqual(v, m_multi[h])
    
    def test_conflict(self):
        self.assertEqual(-log(0.55, 2), self.m1.conflict(self.m2));
        self.assertAlmostEqual(-log(0.55, 2), self.m1.conflict(self.m2, sample_count=1000), 1);
        self.assertEqual(float('inf'), self.m1.conflict(MassFunction({'e': 1})));
    
    def test_normalize(self):
        v = self.m1['a']
        del self.m1['a']
        self.m1.normalize()
        self.assertAlmostEqual(0.2 / (1 - v), self.m1['b'])
        self.assertAlmostEqual(0.1 / (1 - v), self.m1['ad'])
        self.assertAlmostEqual(0.3 / (1 - v), self.m1['abcd'])
        self.assertEqual(0, len(MassFunction().normalize()))
    
    def test_multiple_dimensions(self):
开发者ID:velniukas,项目名称:pyds,代码行数:70,代码来源:pyds_test.py


注:本文中的pyds.MassFunction.combine_disjunctive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。