HMMDecoder Example 1: Loan Default Prediction (from Unsupervised Learner) - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
8.00
1.0
Published
May 2019
Language
English (United States)
Last Update
2019-11-22
dita:mapPath
blj1506016597986.ditamap
dita:ditavalPath
blj1506016597986.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

Suppose you want to find 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

  • InitStateProb: pi_loan
  • TransProb: A_loan
  • EmissionProb: B_loan

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

SQL Call

SELECT * FROM HMMDecoder (
  ON pi_loan AS InitStateProb PARTITION BY model_id ORDER BY model_id, state
  ON A_loan AS TransProb PARTITION BY model_id
  ON B_loan AS EmissionProb PARTITION BY model_id
  ON test_loan_prediction AS observation 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 0 17
1 17 6 1 18
1 17 6 0 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 1 8
2 17 1 1 9
2 17 1 1 10
2 17 1 1 11
2 17 1 1 12
2 17 1 1 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