In this example, the probability of hepatitis depends on all symptoms equally; therefore, the Edges table does not include edge weights.
Input
id | vertex |
---|---|
1 | Jaundice |
2 | Internal bleeding |
3 | Loss of appetite |
4 | Fatigue |
5 | Fever |
6 | Dark urine |
7 | Stupor |
8 | Nausea/vomiting |
9 | Hepatitis |
id | source | target |
---|---|---|
1 | Jaundice | Hepatitis |
2 | Internal bleeding | Hepatitis |
3 | Loss of appetite | Hepatitis |
4 | Fatigue | Hepatitis |
5 | Fever | Hepatitis |
6 | Dark urine | Hepatitis |
7 | Stupor | Hepatitis |
8 | Nausea/vomiting | Hepatitis |
In the ObservationTable, 't' means that the symptom is present and 'f' means that it is absent.
id | vertex | obs |
---|---|---|
1 | Jaundice | t |
2 | Internal bleeding | t |
3 | Loss of appetite | t |
4 | Fatigue | t |
5 | Fever | f |
6 | Dark urine | t |
7 | Stupor | f |
8 | Nausea/vomiting | f |
SQL Call
SELECT * FROM LoopyBeliefPropagation ( ON lbp_edges AS Edges PARTITION BY source ON lbp_vertices AS Vertices PARTITION BY vertex ON lbp_observation AS ObservationTable PARTITION BY vertex USING TargetKey ('target') ObservationColumn ('obs') Accumulate ('vertex') MaxIterNum (20) StopThreshold (1E-10) ) AS dt ORDER BY vertex;
Output
In the output table, 1 means that the symptom is present and 0 means that it is absent. Five of the eight symptoms are present, so the conditional probability of hepatitis is 5/8 (0.625).
vertex prob_true ----------------- --------- dark urine 1.0 fatigue 1.0 fever 0.0 hepatitis 0.625 internal bleeding 1.0 jaundice 1.0 loss of appetite 1.0 nausea/vomiting 0.0 stupor 0.0
Download a zip file of all examples and a SQL script file that creates their input tables from the attachment in the left sidebar.