Skip to content

Instantly share code, notes, and snippets.

@gintsgints
Created September 18, 2014 13:06
Show Gist options
  • Save gintsgints/5256bd7779e406f738ba to your computer and use it in GitHub Desktop.
Save gintsgints/5256bd7779e406f738ba to your computer and use it in GitHub Desktop.
from bayesian.bbn import build_bbn
def f_sex(sex):
return 0.5
def f_waist(waist):
return 0.33333333
def f_bmi(sex, bmi):
if sex == 'f':
if bmi == 'lt25':
return 0.78
if bmi == 'r25_30':
return 0.145
if bmi == 'mt30':
return 0.072
else:
if bmi == 'lt25':
return 0.7
if bmi == 'r25_30':
return 0.241
if bmi == 'mt30':
return 0.059
def f_shape(bmi, waist, shape):
if bmi == 'lt25':
if waist == 'mt102':
if shape == 'fit':
return 0.43
if shape == 'unfit':
return 0.57
if waist == 'r94_102':
if shape == 'fit':
return 0.57
if shape == 'unfit':
return 0.43
if waist == 'lt94':
if shape == 'fit':
return 1.0
if shape == 'unfit':
return 0.0
if bmi == 'r25_30':
if waist == 'mt102':
if shape == 'fit':
return 0.29
if shape == 'unfit':
return 0.71
if waist == 'r94_102':
if shape == 'fit':
return 0.43
if shape == 'unfit':
return 0.57
if waist == 'lt94':
if shape == 'fit':
return 0.86
if shape == 'unfit':
return 0.14
if bmi == 'mt30':
if waist == 'mt102':
if shape == 'fit':
return 0.0
if shape == 'unfit':
return 1.0
if waist == 'r94_102':
if shape == 'fit':
return 0.14
if shape == 'unfit':
return 0.86
if waist == 'lt94':
if shape == 'fit':
return 0.57
if shape == 'unfit':
return 0.43
if __name__ == '__main__':
g = build_bbn(
f_sex,
f_waist,
f_bmi,
f_shape,
domains=dict(
sex=['f', 'm'],
waist=['lt94', 'r94_102', 'mt102'],
bmi=['lt25', 'r25_30', 'mt30'],
shape=['fit', 'unfit']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment