Ejemplo n.º 1
0
 def setUp(self):
     from gPy.Graphs import ADG
     asia_adg = ADG()
     asia_adg.add_vertices([
         'VisitAsia', 'Tuberculosis', 'Smoking', 'Cancer', 'TbOrCa', 'XRay',
         'Bronchitis', 'Dyspnea'
     ])
     asia_adg.put_arrows(
         (['VisitAsia',
           'Tuberculosis'], ['Tuberculosis',
                             'TbOrCa'], ['Cancer',
                                         'TbOrCa'], ['Smoking', 'Cancer'],
          ['Smoking',
           'Bronchitis'], ['Bronchitis',
                           'Dyspnea'], ['TbOrCa',
                                        'Dyspnea'], ['TbOrCa', 'XRay']))
     self.asia_adg = asia_adg
     self.asia_cpts = {
         'VisitAsia': (['Visit', 'No_Visit'], [], [((0.01, 0.99), [])]),
         'Tuberculosis':
         (['Present',
           'Absent'], ['VisitAsia'], [((0.05, 0.95), ['Visit']),
                                      ((0.01, 0.99), ['No_Visit'])]),
         'Smoking': (['Smoker', 'NonSmoker'], [], [((0.5, 0.5), [])]),
         'Cancer':
         (['Present',
           'Absent'], ['Smoking'], [((0.1, 0.9), ['Smoker']),
                                    ((0.01, 0.99), ['NonSmoker'])]),
         'TbOrCa': (['True', 'False'], ['Tuberculosis', 'Cancer'],
                    [((1, 0), ['Present', 'Present']),
                     ((1, 0), ['Present', 'Absent']),
                     ((1, 0), ['Absent', 'Present']),
                     ((0, 1), ['Absent', 'Absent'])]),
         'XRay': (['Abnormal',
                   'Normal'], ['TbOrCa'], [((0.98, 0.02), ['True']),
                                           ((0.05, 0.95), ['False'])]),
         'Bronchitis': (['Present', 'Absent'], ['Smoking'],
                        [((0.6, 0.4), ['Smoker']),
                         ((0.3, 0.7), ['NonSmoker'])]),
         'Dyspnea': (['Present', 'Absent'], ['TbOrCa', 'Bronchitis'],
                     [((0.9, 0.1), ['True', 'Present']),
                      ((0.7, 0.3), ['True', 'Absent']),
                      ((0.8, 0.2), ['False', 'Present']),
                      ((0.1, 0.9), ['False', 'Absent'])])
     }
Ejemplo n.º 2
0
 def setUp(self):
     from gPy.Graphs import ADG
     asia_adg = ADG()
     asia_adg.add_vertices(['VisitAsia', 'Tuberculosis', 'Smoking', 'Cancer',
                    'TbOrCa', 'XRay', 'Bronchitis', 'Dyspnea'])
     asia_adg.put_arrows((['VisitAsia','Tuberculosis'],
                     ['Tuberculosis','TbOrCa'],
                     ['Cancer','TbOrCa'],
                     ['Smoking','Cancer'],
                     ['Smoking','Bronchitis'],
                     ['Bronchitis','Dyspnea'],
                     ['TbOrCa','Dyspnea'],
                     ['TbOrCa','XRay']))
     self.asia_adg = asia_adg
     self.asia_cpts = {
         'VisitAsia': (
         ['Visit',     'No_Visit'], [],
         [
         ((0.01,        0.99),       [])
         ]),
         'Tuberculosis': (
         ['Present',    'Absent'],     ['VisitAsia'],
         [
         ((0.05,        0.95),         ['Visit']),   
         ((0.01,        0.99),         ['No_Visit'])
         ]),
         'Smoking': (
         ['Smoker',       'NonSmoker'], [],
         [
         ((0.5,         0.5),           [])
         ]),
         'Cancer': (
         ['Present',      'Absent'],    ['Smoking'],
         [
         ((0.1,         0.9),           ['Smoker']),    
         ((0.01,        0.99),          ['NonSmoker'])
         ]),
         'TbOrCa': (
         ['True',        'False'],       ['Tuberculosis', 'Cancer'],
         [
         ((1,           0),              ['Present',      'Present']), 
         ((1,           0),              ['Present',      'Absent']),  
         ((1,           0),              ['Absent',       'Present']), 
         ((0,           1),              ['Absent',       'Absent'])
         ]),
         'XRay': (
         ['Abnormal',     'Normal'],    ['TbOrCa'],
         [
         ((0.98,        0.02),          ['True']),   
         ((0.05,        0.95),          ['False'])
         ]),
         'Bronchitis': (
         ['Present',      'Absent'],    ['Smoking'],
         [
         ((0.6,         0.4),           ['Smoker']),    
         ((0.3,         0.7),           ['NonSmoker'])
         ]),
         'Dyspnea': (
         ['Present',      'Absent'],    ['TbOrCa', 'Bronchitis'],
         [
         ((0.9,         0.1),           ['True',   'Present']),    
         ((0.7,         0.3),           ['True',   'Absent']),     
         ((0.8,         0.2),           ['False',  'Present']),    
         ((0.1,         0.9),           ['False',  'Absent'])
         ])
         }