HMMEvaluator Example: Loan Default Prediction - 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ā„¢

The example evaluates a given loan sequence against the two models: model 1 (trained on default loan cases) and model 2 (trained on paid loan cases). The models are trained and referenced from the loan default prediction example from HMMUnsupervised.

Input

The input, test_loan_prediction, is a test loan sequence, which HMMEvaluator uses to predict whether this loan is more likely to be paid in full or to default. The input table does not include observations of 7 (default) or 8 (paid). The sequence of observations in this table is the same for evaluation of both models (that is, model_id = 1 and model_id = 2).

test_loan_prediction
model_id seq_id seq_vertex_id observed_id
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
1      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      
2      

SQL Call

The following SQL call creates the probabilities for each observation of the sequence for each model.

SELECT model_id, seq_id, observed_id, sequence_probability
  FROM HMMEvaluator (
  ON pi_loan AS InitStateProb PARTITION BY model_id
  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 seq_id, seq_vertex_id
  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')
) AS dt ORDER BY seq_id, model_id, sequence_probability DESC;

Output