HMMDecoder Example | Teradata Vantage - HMMDecoder Example: Loan Default Prediction, Unsupervised Learner - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
9.02
9.01
2.0
1.3
Published
February 2022
Language
English (United States)
Last Update
2022-02-10
dita:mapPath
rnn1580259159235.ditamap
dita:ditavalPath
ybt1582220416951.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

This example finds the three hidden states for the table test_loan_prediction in HMMEvaluator Example: Loan Default Prediction, which is an unsupervised loan sequence trained with two models (1 and 2).

Input

  • InitialStateProbs: pi_loan
  • TransitionProbs: A_loan
  • EmissionProbs: B_loan

The preceding models are output by HMMUnsupervised Example: Loan Default Prediction.

SQL Call

SELECT * FROM HMMDecoder (
  ON pi_loan AS InitialStateProbs PARTITION BY model_id ORDER BY model_id, state
  ON A_loan AS TransitionProbs PARTITION BY model_id
  ON B_loan AS EmissionProbs PARTITION BY model_id
  ON test_loan_prediction AS ObservationTable PARTITION BY model_id
    ORDER BY model_id, seq_id, seq_vertex_id ASC
  USING
  InitStateModelColumn ('model_id')
  InitStateColumn ('state')
  InitStateProbColumn ('probability')
  TransAttributeColumn ('model_id')
  TransFromStateColumn('from_state')
  TransToStateColumn('to_state')
  TransProbColumn ('probability')
  EmitModelColumn ('model_id')
  EmitStateColumn ('state')
  EmitObsColumn ('observed')
  EmitProbColumn ('probability')
  ModelColumn ('model_id')
  SeqColumn ('seq_id')
  ObsColumn ('observed_id ')
  Accumulate ('seq_vertex_id ')
) AS dt ORDER BY 1, 2, 5;

Output

For the same sequence, the hidden states are different for each model.

 model_id seq_id observed_id state seq_vertex_id 
 -------- ------ ----------- ----- ------------- 
 1        17        1        2                 0
 1        17        1        2                 1
 1        17        1        2                 2
 1        17        1        2                 3
 1        17        1        2                 4
 1        17        1        2                 5
 1        17        1        2                 6
 1        17        2        2                 7
 1        17        1        2                 8
 1        17        1        2                 9
 1        17        1        2                10
 1        17        1        2                11
 1        17        1        2                12
 1        17        1        2                13
 1        17        3        1                14
 1        17        4        0                15
 1        17        5        1                16
 1        17        6        1                17
 1        17        6        1                18
 1        17        6        1                19
 1        17        6        1                20
 1        17        6        1                21
 1        17        6        1                22
 1        17        6        1                23
 1        17        6        1                24
 1        17        6        0                25
 2        17        1        2                 0
 2        17        1        2                 1
 2        17        1        2                 2
 2        17        1        2                 3
 2        17        1        2                 4
 2        17        1        2                 5
 2        17        1        2                 6
 2        17        2        1                 7
 2        17        1        2                 8
 2        17        1        2                 9
 2        17        1        2                10
 2        17        1        2                11
 2        17        1        2                12
 2        17        1        2                13
 2        17        3        1                14
 2        17        4        0                15
 2        17        5        1                16
 2        17        6        1                17
 2        17        6        1                18
 2        17        6        1                19
 2        17        6        1                20
 2        17        6        1                21
 2        17        6        1                22
 2        17        6        1                23
 2        17        6        1                24
 2        17        6        0                25

Download a zip file of all examples and a SQL script file that creates their input tables.