1.1 - 8.10 - LoopyBeliefPropagation Example: Unequally Weighted Edges - Teradata Vantage

Teradata Vantage™ - Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.1
8.10
Release Date
October 2019
Content Type
Programming Reference
Publication ID
B700-4003-079K
Language
English (United States)

In this example, the probability of hepatitis depends more on some symptoms than others; therefore, the Edges table includes edge weights (and the SQL call includes the EdgeWeight syntax element).

Input

Edges: lbp_weighted_edges
id source target edgewt
1 Jaundice Hepatitis 0.2
2 Internal bleeding Hepatitis 0.15
3 Loss of appetite Hepatitis 0.05
4 Fatigue Hepatitis 0.1
5 Fever Hepatitis 0.1
6 Dark urine Hepatitis 0.25
7 Stupor Hepatitis 0.05
8 Nausea/vomiting Hepatitis 0.1

SQL Call

SELECT * FROM LoopyBeliefPropagation (
  ON lbp_weighted_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')
  EdgeWeight ('edgewt')
  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. The conditional probability of hepatitis is the sum of the weights of the symptoms that are present (0.25 + 0.1 + 0.05 + 0.15 + 0.2 = 0.75).

 vertex            prob_true 
 ----------------- --------- 
 dark urine              1.0
 fatigue                 1.0
 fever                   0.0
 hepatitis              0.75
 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.