cplint on SWISH is a web application for probabilistic logic programming  About  Help  LIFTCOVER-Help  PHIL-Help  PASCAL-Help  Credits  Dismiss

Latest: Threads and Python in LIFTCOVER, course, PHIL examples, book

  
    ? users online
  • Logout
    • Open hangout
    • Open chat for current file
<div class="notebook">

<div class="nb-cell markdown">
# Diabetes Mellitus

From 
 - Steffen Michels, Arjen Hommersom, Peter J. F. Lucas, Marina Velikova:
   A new probabilistic constraint logic programming language based on a generalised distribution semantics.   
   Artif. Intell. 228: 1-44 (2015)

We want to compute the probability of insurgence of diabetes mellitus type 2 given the level of glycated 
hemoglobin (HbA1c).

Various genetic factors play a role on the onset of type 2 diabetes:
</div>

<div class="nb-cell program" data-background="true">
:- use_module(library(mcintyre)).

:- if(current_predicate(use_rendering/1)).
:- use_rendering(c3).
:- use_rendering(graphviz).
:- endif.

:- mc.
:- begin_lpad.

predisposition(average):0.698;predisposition(moderate):0.227;predisposition(high):0.075.
</div>
<div class="nb-cell markdown">
Type2 diabetes has different probability of insurgence given the predisposition:
</div>

<div class="nb-cell program" data-background="true">
dm:0.054:-
  predisposition(average).
dm:0.131:-
  predisposition(moderate).
dm:0.266:-
  predisposition(high).
</div>
<div class="nb-cell markdown">
The level of glucose is represented by two normal distributions:
</div>

<div class="nb-cell program" data-background="true">
gluc_if_dm(G):gaussian(G,7.5,3.8).
gluc_if_not_dm(G):gaussian(G,5.79,0.98).
</div>
<div class="nb-cell markdown">
The level of HbAc1 depends linearly from the level of glucose plus some noise:
</div>

<div class="nb-cell program" data-background="true">
noise_if_dm(N):gaussian(N,0.0,3.3).
noise_if_not_dm(N):gaussian(N,0.0,0.3).

hba1c(H):-
    dm,
    gluc_if_dm(G),
    noise_if_dm(N),
    {H=:=1.4+0.92*G+N}.

hba1c(H):-
    \+ dm,
    gluc_if_not_dm(G),
    noise_if_not_dm(N),
    {H=:=0.6+0.9*G+N}.
</div>
<div class="nb-cell markdown">
We observe that the level of HbA1c is larger than 7.2:
</div>
<div class="nb-cell program" data-background="true">
e:- hba1c(H),{H>7.2}.
:- end_lpad.
</div>
<div class="nb-cell markdown">
We want to compute the probability of diabetes type 2 a priori and given the evidence:
</div>
<div class="nb-cell query">
mc_sample(dm,1000,Prob).
</div>
<div class="nb-cell query">
mc_mh_sample(dm,e,10000,Prob).
</div>
</div>