Ejemplo n.º 1
0
T, F = True, False

burglary = BayesNet([('Burglary', '', 0.001), ('Earthquake', '', 0.002),
                     ('Alarm', 'Burglary Earthquake', {
                         (T, T): 0.95,
                         (T, F): 0.94,
                         (F, T): 0.29,
                         (F, F): 0.001
                     }), ('JohnCalls', 'Alarm', {
                         T: 0.90,
                         F: 0.05
                     }), ('MaryCalls', 'Alarm', {
                         T: 0.70,
                         F: 0.01
                     })])
burglary.label = 'Burglary Example, Fig. 14.2'

storm = BayesNet([
    ('Thunderstorm', '', 0.005),
    ('Earthquake', '', 0.002),
    ('Rain', '', 0.02),
    ('Loud', 'Thunderstorm Earthquake Rain', {
        (T, T, T): 0.99,
        (T, F, T): 0.65,
        (T, T, F): 0.95,
        (T, F, F): 0.85,
        (F, T, T): 0.80,
        (F, T, F): 0.50,
        (F, F, T): 0.20,
        (F, F, F): 0.05,
    }),
Ejemplo n.º 2
0
        F: 0.05
    }),
    ('Outside', 'Sleeping Sad', {
        (T, T): 0.005,
        (T, F): 0.01,
        (F, T): 0.28,
        (F, F): 0.43
    }),
    ('Exercise', 'Outside Moving', {
        (T, T): 0.6,
        (T, F): 0.0,
        (F, T): 0.34,
        (F, F): 0.0
    }),
])
depressedStudent.label = 'Depressed Student: is he sleeping, moving, drooling or outside?'

examples = {
    depressedStudent: [
        {
            'variable': 'Sad',
            'evidence': {
                'Outside': T,
                'Drooling': T
            },
        },
        {
            'variable': 'Homework',
            'evidence': {
                'Outside': F,
                'Moving': F
Ejemplo n.º 3
0
burglary = BayesNet([('Burglary', '', 0.001), ('Earthquake', '', 0.002),
                     ('Alarm', 'Burglary Earthquake', {
                         (T, T): 0.95,
                         (T, F): 0.94,
                         (F, T): 0.29,
                         (F, F): 0.001
                     }), ('JohnCalls', 'Alarm', {
                         T: 0.90,
                         F: 0.05
                     }), ('MaryCalls', 'Alarm', {
                         T: 0.70,
                         F: 0.01
                     })])

burglary.label = 'Burglary Example, Fig. 14.2'

famous = BayesNet([
    # will you get famous?
    # statistics recevied from https://nypost.com/2009/07/25/you-are-not-going-to-be-famous/ and
    ('liveInAmerica', '', 0.04),
    ('liveInNashville', '', 0.002),
    ('Famous', 'liveInAmerica liveInNashville', {
        (T, T): 0.000000024,
        (T, F): 0.000000024,
        (F, T): 0.0000000012,
        (F, F): 0.0000006
    }),
    ('Actor', 'Famous', {
        T: 0.00041,
        F: 0.9
Ejemplo n.º 4
0
T, F = True, False

death = BayesNet([('Overweight', '', 0.339), ('HighStress', '', 0.72),
                  ('HeartAttack', 'Overweight HighStress', {
                      (T, T): 0.72,
                      (T, F): 0.15,
                      (F, T): 0.12,
                      (F, F): 0.003
                  }), ('OldAge', '', 0.147),
                  ('Death', 'HeartAttack OldAge', {
                      (T, T): 0.749,
                      (T, F): 0.25,
                      (F, T): 0.0009,
                      (F, F): 0.001
                  })])
death.label = 'Death and Heart Attacks'

examples = {
    death: [
        {
            'variable': 'Overweight',
            'evidence': {
                'Death': T,
            },
        },
        {
            'variable': 'Death',
            'evidence': {
                'HeartAttack': T,
                'OldAge': F
            },
Ejemplo n.º 5
0
        (F, T, T): 0.62,
        (F, T, F): 0.9,
        (F, F, T): 0.7,
        (F, F, F): 0.2
    }),
    # my reaction to my cat sitting on me
    ('Pets', 'CatSits', {
        T: 0.7,
        F: 0.03
    }),
    ('Feeds', 'CatSits', {
        T: .2,
        F: 0.85
    })
])
cat.label = "Interactions with my cat"

examples = {
    cat: [{
        'variable': 'HW',
        'evidence': {
            'Pets': T,
            'Feeds': F
        }
    }, {
        'variable': 'HW',
        'evidence': {
            'Pets': F,
            'Feeds': F
        }
    }, {
Ejemplo n.º 6
0
from probability import BayesNet

T, F = True, False

burglary = BayesNet([
    ('Burglary', '', 0.001),
    ('Earthquake', '', 0.002),
    ('Alarm', 'Burglary Earthquake',
     {(T, T): 0.95,
      (T, F): 0.94,
      (F, T): 0.29,
      (F, F): 0.001}),
    ('JohnCalls', 'Alarm', {T: 0.90, F: 0.05}),
    ('MaryCalls', 'Alarm', {T: 0.70, F: 0.01})
])
burglary.label = 'Burglary Example, Fig. 14.2'

examples = {
    burglary: [
        {'variable': 'Burglary',
         'evidence': {'JohnCalls':T, 'MaryCalls':T},
         },
        {'variable': 'Burglary',
         'evidence': {'JohnCalls':F, 'MaryCalls':T},
         },
        {'variable': 'Earthquake',
         'evidence': {'JohnCalls':T, 'MaryCalls':T},
         },
    ],
}
Ejemplo n.º 7
0
    ('Female', '', 0.51),
    ('LGB', '', 0.054),
    ('Smoker', 'LGB Female',
     {(T, T): 0.3047,
      (T, F): 0.3046,
      (F, T): 0.1885,
      (F, F): 0.2202}),
    ('LungCancer', 'Smoker Female',
     {(T, T): 0.095,
      (T, F): 0.159,
      (F, T): 0.004,
      (F, F): 0.002}),
    ('PrematureDeath', 'LungCancer', {T: 0.86, F: 0.0134}),
    # ('Smoker', 'LGB', {T: 0.205, F: 0.153})
])
smoking.label = 'Smoking Example'

examples = {
    smoking: [
        {'variable': 'LungCancer',
         'evidence': {'LGB':T},
         },
        {'variable': 'LGB',
         'evidence': {'PrematureDeath':F},
         },
        {'variable': 'PrematureDeath',
         'evidence': {'Female':T, 'LGB':T},
         },
        {'variable': 'Smoker',
         'evidence': {'Female':F, 'PrematureDeath':T},
         },
Ejemplo n.º 8
0
                               (F, F, T): 0.75,
                               (F, F, F): 0.09
                           }),
                          ('CantFindSemiColon', 'CompileError', {
                              T: 0.7,
                              F: 0.3
                          }), ('ArrayIsNull', 'CompileError', {
                              T: 0.3,
                              F: 0.85
                          }),
                          ('OhYeahForgotThat', 'CompileError', {
                              T: 0.8,
                              F: 0.1
                          })])

compile_error.label = 'Programming Compile Error Correlation With Cause (Hypothetical)'

examples = {
    compile_error: [{
        'variable': 'ExtraSemicolon',
        'evidence': {
            'CantFindSemiColon': T,
            'OhYeahForgotThat': T
        }
    }, {
        'variable': 'MissingSemicolon',
        'evidence': {
            'ArrayIsNull': F,
            'OhYeahForgotThat': T
        }
    }, {
Ejemplo n.º 9
0
from probability import BayesNet

T, F = True, False

nashvilleWeather = BayesNet([
    ('Rain', '', 0.36),
    ('Freezing', '', 0.27),
    ('CarAccident', 'Rain Freezing',
     {(T, T): 0.95,
      (T, F): 0.79,
      (F, T): 0.29,
      (F, F): 0.001}),
    ('InjuriesReported', 'CarAccident', {T: 0.89, F: 0.09}),
    ('DeathReported', 'CarAccident', {T: 0.95, F: 0.02})
])
nashvilleWeather.label = 'Nashville Weather Correlation With Accidents (Hypothetical)'

examples = {
    nashvilleWeather: [
        {'variable': 'Rain',
         'evidence': {'InjuriesReported': T, 'DeathReported': T},
         },
        {'variable': 'Freezing',
         'evidence': {'InjuriesReported': T, 'DeathReported': T},
         },
        {'variable': 'CarAccident',
         'evidence': {'InjuriesReported': T, 'Rain': F},
         },
        {'variable': 'DeathReported',
         'evidence': {'Rain': T, 'Freezing': T}
        }
Ejemplo n.º 10
0
    ('Sleep', '', 0.6),
    ('PlayGames', '', 0.1),
    ('Pass', 'Study Sleep PlayGames',
     {(T, T, T): 0.85,
      (T, T, F): 0.98,
      (F, T, T): 0.1,
      (F, F, T): 0.001,
      (F, F, F): 0.01,
      (T, F, T): 0.51,
      (F, T, F): 0.21,
      (T, F, F): 0.78}),
    ('BadDream', 'Pass', {T: 0.4, F: 0.6}),
    ('BeatGame', 'Pass', {T: 0.01, F: 0.2}),
    ('GoodDream', 'Pass', {T: 0.70, F: 0.1})
])
test.label = 'Pass Test'

examples = {
    test: [
        {'variable': 'Study',
         'evidence': {'BadDream':T, 'GoodDream':T},
         },
        {'variable': 'Study',
         'evidence': {'BadDream':F, 'GoodDream':T},
         },
        {'variable': 'PlayGames',
         'evidence': {'BeatGame':F, 'GoodDream':F},
         },
        {'variable': 'PlayGames',
         'evidence': {'BeatGame':T, 'GoodDream':T},
         },
Ejemplo n.º 11
0
T, F = True, False

burglary = BayesNet([('Burglary', '', 0.001), ('Earthquake', '', 0.002),
                     ('Alarm', 'Burglary Earthquake', {
                         (T, T): 0.95,
                         (T, F): 0.94,
                         (F, T): 0.29,
                         (F, F): 0.001
                     }), ('JohnCalls', 'Alarm', {
                         T: 0.90,
                         F: 0.05
                     }), ('MaryCalls', 'Alarm', {
                         T: 0.70,
                         F: 0.01
                     })])
burglary.label = 'Burglary Example, Fig. 14.2'
Bball = BayesNet([('StephPlays', '', 0.96), ('KevinPlays', '', 0.76),
                  ('DraymondPlays', '', .92),
                  ('StephScores+25', 'StephPlays', {
                      T: .48,
                      F: 0.
                  }), ('KevinScores+25', 'KevinPlays', {
                      (T): .56,
                      (F): 0.
                  }),
                  ('Lose', 'KevinScores+25 StephScores+25', {
                      (T, T): .02,
                      (T, F): .06,
                      (F, T): .06,
                      (F, F): .96
                  }),
Ejemplo n.º 12
0
death = BayesNet([
    ('Overweight', '', 0.339),
    ('HighStress', '', 0.72),
    ('HeartAttack', 'Overweight HighStress',
     {(T, T): 0.72,
      (T, F): 0.15,
      (F, T): 0.12,
      (F, F): 0.003}),
    ('OldAge', '', 0.147),
    ('Death', 'HeartAttack OldAge',
     {(T, T): 0.749,
      (T, F): 0.25,
      (F, T): 0.0009,
      (F, F): 0.001})
])
death.label = 'Death and Heart Attacks'

examples = {
    death: [
        {'variable': 'Overweight',
         'evidence': {'Death':T,},
         },
        {'variable': 'Death',
         'evidence': {'HeartAttack':T, 'OldAge':F},
         },
        {'variable': 'HighStress',
         'evidence': {'Death':F, },
         },
        {'variable': 'OldAge',
         'evidence': {'HeartAttack':T, },
        },
Ejemplo n.º 13
0
    ('LegDay', '', .33),
    ('ArmsDay', '', 0.33),
    ('Cardio', '', 0.33),
    ('Tired', 'LegDay ArmDay', 'Cardio',
     {(T, T, T): 0.1,
      (T, T, F): 0.1,
      (T, F, T): 0.7,
      (T, F, F): 0.8,
      (F, T, T): 0.7,
      (F, T, F): 0.9,
      (F, F, T): 0.9,
      (F, F, F): 0.5}),
    ('Quit', 'Tired', {T: 0.70, F: 0.01}),
    ('Push', 'Tired', {T: 0.90, F: 0.10})
])
gym.label = 'Gym Day'

examples = {
    gym: [
        {'variable': 'Legday',
         'evidence': {'Quit': T, 'Push': F}
         },
        {'variable': 'Legday',
         'evidence': {'Quit': F, 'Push': F}
         },
        {'variable': 'Armday',
         'evidence': {'Quit': T, 'Push': T}
         },
        {'variable': 'Cardio',
         'evidence': {'Quit': F, 'Push': T}
         }
Ejemplo n.º 14
0
T, F = True, False

burglary = BayesNet([('Pollution', '', 0.1), ('Smoker', '', 0.3),
                     ('Cancer', 'Pollution Smoker', {
                         (T, T): 0.05,
                         (T, F): 0.02,
                         (F, T): 0.03,
                         (F, F): 0.001
                     }), ('XRay', 'Cancer', {
                         T: 0.90,
                         F: 0.20
                     }), ('Dyspnoea', 'Cancer', {
                         T: 0.65,
                         F: 0.30
                     })])
burglary.label = 'Lung Cancer Probability'

examples = {
    burglary: [
        {
            'variable': 'Cancer',
            'evidence': {
                'Dyspnoea': T,
                'Smoker': T
            },
        },
        {
            'variable': 'Smoker',
            'evidence': {
                'Xray': T,
                'Cancer': F
Ejemplo n.º 15
0
from probability import BayesNet

T, F = True, False

coffee = BayesNet([
    ('Tired', '', 0.24),
    ('Working', '', 0.45),
    ('Coffee', 'Tired Working',
     {(T, T): 0.97,
      (T, F): 0.38,
      (F, T): 0.29,
      (F, F): 0.05}),
    ('Energy', 'Coffee', {T: 0.83, F: 0.21}),
    ('Jitters', 'Coffee', {T: 0.19, F: 0.01})
])
coffee.label = 'Probability of getting coffee'

examples = {
    coffee: [
        {'variable': 'Tired',
         'evidence': {'Energy':T, 'Jitters':T},
         },
        {'variable': 'Tired',
         'evidence': {'Energy':F, 'Jitters':T},
         },
        {'variable': 'Working',
         'evidence': {'Energy':T, 'Jitters':T},
         },
    ],
}
Ejemplo n.º 16
0
from probability import BayesNet

T, F = True, False

snowDay = BayesNet([
    ('snow', '', 0.022),
    ('windChill', '', 0.017),
    ('advisory', 'snow windChill',
     {(T, T): 0.62,
      (T, F): 0.48,
      (F, T): 0.41,
      (F, F): 0.0001}),
    ('noSchool', 'advisory', {T: 0.70, F: 0.005}),
    ('extremeWarning', 'advisory', {T: 0.16, F: 0.002})
])
snowDay.label = 'snowDay shows various weather probabilities that effect the chances of a snow day in Buffalo, New York.'

examples = {
    snowDay: [
        {'variable': 'snow',
         'evidence': {'noSchool':T, 'extremeWarning':T},
         },
        {'variable': 'windChill',
         'evidence': {'noSchool': F, 'advisory': T},
         },
        {'variable': 'advisory',
         'evidence': {'noSchool': T, 'windChill': F},
         },
        {'variable': 'extremeWarning',
         'evidence': {'snow': T, 'windChill': T},
         },
Ejemplo n.º 17
0
      (F, F, T): 0.89,
      (F, F, F): 0.01}),
    ('Moving', 'Sleeping', {T: 0.5, F: 0.87}),
    ('Drooling', 'Sleeping', {T: 0.56, F: 0.05}),
    ('Outside', 'Sleeping Sad',
     {(T, T): 0.005,
      (T, F): 0.01,
      (F, T): 0.28,
      (F, F): 0.43}),
    ('Exercise', 'Outside Moving',
     {(T, T): 0.6,
      (T, F): 0.0,
      (F, T): 0.34,
      (F, F): 0.0}),
])
depressedStudent.label = 'Depressed Student: is he sleeping, moving, drooling or outside?'

examples = {
    depressedStudent: [
        {'variable': 'Sad',
         'evidence': {'Outside':T, 'Drooling':T},
         },
        {'variable': 'Homework',
         'evidence': {'Outside':F, 'Moving':F},
         },
        {'variable': 'Tired',
         'evidence': {'Outside':F, 'Drooling':T},
         },
        {'variable': 'Sleeping',
         'evidence': {'Outside':T, 'Drooling':F},
         },
Ejemplo n.º 18
0
T, F = True, False

cancer = BayesNet([
    ('Pollution', '', 0.10),
    ('Smoker','', 0.90),
    ('LungCancer', 'Pollution Smoker',
     {(T, T): 0.987,
      (T, F): 0.10,
      (F, T): 0.87,
      (F, F): 0.09}),
    ('XRay', 'LungCancer', {T: 0.90, F: 0.10}),
    ('Dyspnoea', 'LungCancer', {T: 0.70, F: 0.30}),
    ('Death', 'LungCancer', {T: 0.87, F: 0.13}),
])
cancer.label = 'Lung Cancer Example'

examples = {
    cancer: [
        {'variable': 'LungCancer',
         'evidence': {'Death':T, 'Pollution':T},
         },
        {'variable': 'Death',
         'evidence': {'LungCancer':F, 'Smoker':T},
         },
        {'variable': 'Smoker',
         'evidence': {'LungCancer':T, 'Pollution':T},
         },
        {'variable': 'Pollution',
         'evidence': {'LungCancer':T, 'Xray':T},
        },
Ejemplo n.º 19
0
        (F, F): 0.09
    }),
    ('XRay', 'LungCancer', {
        T: 0.90,
        F: 0.10
    }),
    ('Dyspnoea', 'LungCancer', {
        T: 0.70,
        F: 0.30
    }),
    ('Death', 'LungCancer', {
        T: 0.87,
        F: 0.13
    }),
])
cancer.label = 'Lung Cancer Example'

examples = {
    cancer: [{
        'variable': 'LungCancer',
        'evidence': {
            'Death': T,
            'Pollution': T
        },
    }, {
        'variable': 'Death',
        'evidence': {
            'LungCancer': F,
            'Smoker': T
        },
    }, {
Ejemplo n.º 20
0
grass = BayesNet([('Raining', '', 0.1), ('Sprinklers', '', 0.4),
                  ('GrassWet', 'Raining Sprinklers', {
                      (T, T): 0.99,
                      (T, F): 0.82,
                      (F, T): 0.94,
                      (F, F): 0.001
                  }), ('DadIsHappy', 'GrassWet', {
                      T: 0.90,
                      F: 0.05
                  }),
                  ('AquaphobicNeighborIsNotHappy', 'GrassWet', {
                      T: 0.70,
                      F: 0.01
                  })])
grass.label = 'WetGrass'

examples = {
    grass: [
        {
            'variable': 'Raining',
            'evidence': {
                'DadIsHappy': T,
                'AquaphobicNeighborIsNotHappy': T
            },
        },
        {
            'variable': 'Sprinklers',
            'evidence': {
                'DadIsHappy': F,
                'AquaphobicNeighborIsNotHappy': T
Ejemplo n.º 21
0
    # ('HitCar', 'AccidentB', {T: 0.60, F: 0.40}),
    # ('HitGuardRail', 'AccidentB', {T: 0.80, F: 0.20}),
    #
    # # ('HitCar', 'AccidentC', {T: 0.60, F: 0.40}),
    # ('HitGuardRail', 'AccidentC', {T: 0.80, F: 0.20}),
    #
    # ('HitCar', 'AccidentD', {T: 0.60, F: 0.40}),
    # ('HitGuardRail', 'AccidentD', {T: 0.80, F: 0.20}),
    #
    # ('HitCar', 'AccidentE', {T: 0.60, F: 0.40}),
    # ('HitGuardRail', 'AccidentE', {T: 0.80, F: 0.20}),
    #
    # ('HitCar', 'AccidentF', {T: 0.60, F: 0.40}),
    # ('HitGuardRail', 'AccidentF', {T: 0.80, F: 0.20})
])
CarAccidents.label = 'Car Accident Example, Fig. 1'

examples = {
    CarAccidents: [
        # Texting
        {
            'variable': 'Texting',
            'evidence': {
                'HitCar': T,
                'HitGuardRail': T
            },
        },
        {
            'variable': 'Texting',
            'evidence': {
                'HitCar': F,
Ejemplo n.º 22
0
     {
         (T, T, T): 0.2,
         (T, T, F): 0.5,
         (T, F, T): 0.1,
         (T, F, F): 0.7,
         (F, T, T): 0.1,
         (F, T, F): 0.4,
         (F, F, T): 0.75,
         (F, F, F): 0.09
     }),
    ('CantFindSemiColon', 'CompileError', {T: 0.7, F: 0.3}),
    ('ArrayIsNull', 'CompileError', {T: 0.3, F: 0.85}),
    ('OhYeahForgotThat', 'CompileError', {T: 0.8, F: 0.1})
])

compile_error.label = 'Programming Compile Error Correlation With Cause (Hypothetical)'

examples = {
    compile_error: [
        {'variable': 'ExtraSemicolon',
         'evidence': {'CantFindSemiColon': T, 'OhYeahForgotThat': T}
         },
        {'variable': 'MissingSemicolon',
         'evidence': {'ArrayIsNull': F, 'OhYeahForgotThat': T}
         },
        {'variable': 'IndexOutOfRange',
         'evidence': {'ArrayIsNull': T, 'MissingSemicolon': F}
         },
        {'variable': 'ArrayIsNull',
         'evidence': {'IndexOutOfRange': T}
         },
Ejemplo n.º 23
0
                     (F, F, T): 0.001,
                     (F, F, F): 0.01,
                     (T, F, T): 0.51,
                     (F, T, F): 0.21,
                     (T, F, F): 0.78
                 }), ('BadDream', 'Pass', {
                     T: 0.4,
                     F: 0.6
                 }), ('BeatGame', 'Pass', {
                     T: 0.01,
                     F: 0.2
                 }), ('GoodDream', 'Pass', {
                     T: 0.70,
                     F: 0.1
                 })])
test.label = 'Pass Test'

examples = {
    test: [
        {
            'variable': 'Study',
            'evidence': {
                'BadDream': T,
                'GoodDream': T
            },
        },
        {
            'variable': 'Study',
            'evidence': {
                'BadDream': F,
                'GoodDream': T
Ejemplo n.º 24
0
         (T, T, T): 0.90,
         (T, T, F): 0.13,
         (T, F, T): 0.85,
         (T, F, F): 0.07,
         (F, T, T): 0.0,
         (F, T, F): 0.0,
         (F, F, T): 0.99,
         (F, F, F): 0.95


     }),
    ('Jason', 'Dead', {T: 0.01, F: 0.90}),
    ('Lauren', 'Dead', {T: 0.20, F: 0.50}),
    ('Zach', 'Dead', {T: 0.49, F: 0.11})
])
Aids.label = 'Probability of Death with HIV/AIDS'

examples = {
    Aids: [
        {'variable': 'HIV',
         'evidence': {'Jason':T, 'Lauren':T, 'Zach':T},
         },
        {'variable': 'HIV',
         'evidence': {'Jason':F, 'Lauren':T, 'Zach':T},
         },
        {'variable': 'HIV',
         'evidence': {'Jason':F, 'Lauren':F, 'Zach':T},
         },
        {'variable': 'HIV',
         'evidence': {'Jason':F, 'Lauren':F, 'Zach':F},
         },